mongodb_dbase.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) 2014 Daniel-Constantin Mierla (asipto.com)
  3. *
  4. * This file is part of Kamailio, a free SIP server.
  5. *
  6. * Kamailio is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. * Kamailio is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #ifndef _MONGODB_DBASE_H_
  22. #define _MONGODB_DBASE_H_
  23. #include "../../lib/srdb1/db_con.h"
  24. #include "../../lib/srdb1/db_res.h"
  25. #include "../../lib/srdb1/db_key.h"
  26. #include "../../lib/srdb1/db_op.h"
  27. #include "../../lib/srdb1/db_val.h"
  28. /*
  29. * Initialize database connection
  30. */
  31. db1_con_t* db_mongodb_init(const str* _sqlurl);
  32. /*
  33. * Close a database connection
  34. */
  35. void db_mongodb_close(db1_con_t* _h);
  36. /*
  37. * Free all memory allocated by get_result
  38. */
  39. int db_mongodb_free_result(db1_con_t* _h, db1_res_t* _r);
  40. /*
  41. * Do a query
  42. */
  43. int db_mongodb_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, const db_val_t* _v,
  44. const db_key_t* _c, const int _n, const int _nc, const db_key_t _o, db1_res_t** _r);
  45. /*
  46. * Fetch rows from a result
  47. */
  48. int db_mongodb_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
  49. /*
  50. * Raw SQL query
  51. */
  52. int db_mongodb_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
  53. /*
  54. * Insert a row into table
  55. */
  56. int db_mongodb_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n);
  57. /*
  58. * Delete a row from table
  59. */
  60. int db_mongodb_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v,
  61. const int _n);
  62. /*
  63. * Update a row in table
  64. */
  65. int db_mongodb_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v,
  66. const db_key_t* _uk, const db_val_t* _uv, const int _n, const int _un);
  67. /*
  68. * Just like insert, but replace the row if it exists
  69. */
  70. int db_mongodb_replace(const db1_con_t* handle, const db_key_t* keys, const db_val_t* vals,
  71. const int n, const int _un, const int _m);
  72. /*
  73. * Store name of table that will be used by
  74. * subsequent database functions
  75. */
  76. int db_mongodb_use_table(db1_con_t* _h, const str* _t);
  77. #endif /* _MONGODB_BASE_H_ */