@@ -161,21 +161,23 @@ typedef struct {
161161 * @param file_name The database file name (.crabdb enforced).
162162 * @param document The document string to insert.
163163 * @param param_list Optional FSON parameter list for structured data (can be NULL).
164+ * @param type Document type as string parameter.
164165 * @return FOSSIL_NOSHELL_ERROR_SUCCESS on success, otherwise error code.
165166 */
166- fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_insert (const char *file_name, const char *document, const char *param_list);
167+ fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_insert (const char *file_name, const char *document, const char *param_list, const char *type );
167168
168169/* *
169170 * @brief Inserts a document and returns a unique internal ID.
170171 *
171172 * @param file_name The database file name (.crabdb enforced).
172173 * @param document The document string to insert.
173174 * @param param_list Optional FSON parameter list for structured data (can be NULL).
175+ * @param type Document type as string parameter.
174176 * @param out_id Buffer to store generated document ID.
175177 * @param id_size Size of the buffer.
176178 * @return FOSSIL_NOSHELL_ERROR_SUCCESS on success, otherwise error code.
177179 */
178- fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_insert_with_id (const char *file_name, const char *document, const char *param_list, char *out_id, size_t id_size);
180+ fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_insert_with_id (const char *file_name, const char *document, const char *param_list, const char *type, char *out_id, size_t id_size);
179181
180182/* *
181183 * @brief Finds a document based on a query string.
@@ -184,9 +186,10 @@ fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_insert_with_id(const cha
184186 * @param query The query string to search.
185187 * @param result Buffer to store the matching document.
186188 * @param buffer_size Size of the buffer.
189+ * @param type_id Optional type id parameter.
187190 * @return FOSSIL_NOSHELL_ERROR_SUCCESS on success, otherwise error code.
188191 */
189- fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_find (const char *file_name, const char *query, char *result, size_t buffer_size);
192+ fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_find (const char *file_name, const char *query, char *result, size_t buffer_size, const char *type_id );
190193
191194/* *
192195 * @brief Finds documents using a callback filter function.
@@ -205,9 +208,10 @@ fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_find_cb(const char *file
205208 * @param query Query string to locate document(s).
206209 * @param new_document New document content to replace matching documents.
207210 * @param param_list Optional FSON parameter list for structured data (can be NULL).
211+ * @param type_id Optional type id parameter.
208212 * @return FOSSIL_NOSHELL_ERROR_SUCCESS on success, otherwise error code.
209213 */
210- fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_update (const char *file_name, const char *query, const char *new_document, const char *param_list);
214+ fossil_bluecrab_noshell_error_t fossil_bluecrab_noshell_update (const char *file_name, const char *query, const char *new_document, const char *param_list, const char *type_id );
211215
212216/* *
213217 * @brief Removes a document from the database based on a query string.
@@ -388,25 +392,29 @@ namespace fossil {
388392 * @param file_name The database file name (.crabdb enforced).
389393 * @param document The document string to insert.
390394 * @param param_list Optional FSON parameter list for structured data (can be empty).
395+ * @param type Document type as string parameter (can be empty).
391396 * @return FOSSIL_NOSHELL_ERROR_SUCCESS on success, otherwise error code.
392397 */
393- static fossil_bluecrab_noshell_error_t insert (const std::string& file_name, const std::string& document, const std::string& param_list = " " ) {
398+ static fossil_bluecrab_noshell_error_t insert (const std::string& file_name, const std::string& document, const std::string& param_list = " " , const std::string& type = " " ) {
394399 const char * param = param_list.empty () ? nullptr : param_list.c_str ();
395- return fossil_bluecrab_noshell_insert (file_name.c_str (), document.c_str (), param);
400+ const char * type_str = type.empty () ? nullptr : type.c_str ();
401+ return fossil_bluecrab_noshell_insert (file_name.c_str (), document.c_str (), param, type_str);
396402 }
397403
398404 /* *
399405 * @brief Inserts a document and returns a unique internal ID.
400406 * @param file_name The database file name (.crabdb enforced).
401407 * @param document The document string to insert.
402408 * @param param_list Optional FSON parameter list for structured data (can be empty).
409+ * @param type Document type as string parameter (can be empty).
403410 * @param out_id Reference to a string to store the generated document ID.
404411 * @return FOSSIL_NOSHELL_ERROR_SUCCESS on success, otherwise error code.
405412 */
406- static fossil_bluecrab_noshell_error_t insert_with_id (const std::string& file_name, const std::string& document, const std::string& param_list, std::string& out_id) {
413+ static fossil_bluecrab_noshell_error_t insert_with_id (const std::string& file_name, const std::string& document, const std::string& param_list, const std::string& type, std::string& out_id) {
407414 char buffer[128 ] = {0 };
408415 const char * param = param_list.empty () ? nullptr : param_list.c_str ();
409- fossil_bluecrab_noshell_error_t err = fossil_bluecrab_noshell_insert_with_id (file_name.c_str (), document.c_str (), param, buffer, sizeof (buffer));
416+ const char * type_str = type.empty () ? nullptr : type.c_str ();
417+ fossil_bluecrab_noshell_error_t err = fossil_bluecrab_noshell_insert_with_id (file_name.c_str (), document.c_str (), param, type_str, buffer, sizeof (buffer));
410418 if (err == FOSSIL_NOSHELL_ERROR_SUCCESS) {
411419 out_id = buffer;
412420 }
@@ -418,11 +426,13 @@ namespace fossil {
418426 * @param file_name The database file name.
419427 * @param query The query string to search.
420428 * @param result Reference to a string to store the matching document.
429+ * @param type_id Optional type id parameter (can be empty).
421430 * @return FOSSIL_NOSHELL_ERROR_SUCCESS on success, otherwise error code.
422431 */
423- static fossil_bluecrab_noshell_error_t find (const std::string& file_name, const std::string& query, std::string& result) {
432+ static fossil_bluecrab_noshell_error_t find (const std::string& file_name, const std::string& query, std::string& result, const std::string& type_id = " " ) {
424433 char buffer[4096 ] = {0 };
425- fossil_bluecrab_noshell_error_t err = fossil_bluecrab_noshell_find (file_name.c_str (), query.c_str (), buffer, sizeof (buffer));
434+ const char * type_str = type_id.empty () ? nullptr : type_id.c_str ();
435+ fossil_bluecrab_noshell_error_t err = fossil_bluecrab_noshell_find (file_name.c_str (), query.c_str (), buffer, sizeof (buffer), type_str);
426436 if (err == FOSSIL_NOSHELL_ERROR_SUCCESS) {
427437 result = buffer;
428438 }
@@ -435,11 +445,13 @@ namespace fossil {
435445 * @param query Query string to locate document(s).
436446 * @param new_document New document content to replace matching documents.
437447 * @param param_list Optional FSON parameter list for structured data (can be empty).
448+ * @param type_id Optional type id parameter (can be empty).
438449 * @return FOSSIL_NOSHELL_ERROR_SUCCESS on success, otherwise error code.
439450 */
440- static fossil_bluecrab_noshell_error_t update (const std::string& file_name, const std::string& query, const std::string& new_document, const std::string& param_list = " " ) {
451+ static fossil_bluecrab_noshell_error_t update (const std::string& file_name, const std::string& query, const std::string& new_document, const std::string& param_list = " " , const std::string& type_id = " " ) {
441452 const char * param = param_list.empty () ? nullptr : param_list.c_str ();
442- return fossil_bluecrab_noshell_update (file_name.c_str (), query.c_str (), new_document.c_str (), param);
453+ const char * type_str = type_id.empty () ? nullptr : type_id.c_str ();
454+ return fossil_bluecrab_noshell_update (file_name.c_str (), query.c_str (), new_document.c_str (), param, type_str);
443455 }
444456
445457 /* *
0 commit comments