/* Save/Update BSON into 'coll' */
EJDB_EXPORT bool ejdbsavebson(EJCOLL *jcoll, bson *bs, bson_oid_t *oid) {
- assert(jcoll && bs);
+ assert(jcoll);
+ if (!bs || bs->err || !bs->finished) {
+ _ejdbsetecode(jcoll->jb, JBEINVALIDBSON, __FILE__, __LINE__, __func__);
+ return false;
+ }
if (!JBISOPEN(jcoll->jb)) {
_ejdbsetecode(jcoll->jb, TCEINVALID, __FILE__, __LINE__, __func__);
return false;
}
EJDB_EXPORT EJQ* ejdbcreatequery(EJDB *jb, bson *qobj, bson *orqobjs, int orqobjsnum, bson *hints) {
+ assert(jb);
+ if (!qobj || qobj->err || !qobj->finished) {
+ _ejdbsetecode(jb, JBEINVALIDBSON, __FILE__, __LINE__, __func__);
+ return NULL;
+ }
EJQ *q;
TCCALLOC(q, 1, sizeof (*q));
if (qobj) {
}
}
if (hints) {
+ if (hints->err || !hints->finished) {
+ _ejdbsetecode(jb, JBEINVALIDBSON, __FILE__, __LINE__, __func__);
+ return NULL;
+ }
q->hints = bson_create();
if (bson_copy(q->hints, hints)) {
goto error;
* @param unlink It true the collection db file and all of its index files will be removed.
* @return If successful return true, otherwise return false.
*/
-EJDB_EXPORT bool ejdbrmcoll(EJDB *jb, const char* colname, bool unlinkfile);
+EJDB_EXPORT bool ejdbrmcoll(EJDB *jb, const char *colname, bool unlinkfile);
/**
* Persist BSON object in the collection.
* @param bson BSON object id pointer.
* @return If successful return true, otherwise return false.
*/
-EJDB_EXPORT bool ejdbsavebson(EJCOLL* coll, bson* bs, bson_oid_t* oid);
+EJDB_EXPORT bool ejdbsavebson(EJCOLL *coll, bson *bs, bson_oid_t *oid);
/**
* Remove BSON object from collection.
* @param oid BSON object id pointer.
* @return
*/
-EJDB_EXPORT bool ejdbrmbson(EJCOLL* coll, bson_oid_t* oid);
+EJDB_EXPORT bool ejdbrmbson(EJCOLL *coll, bson_oid_t *oid);
/**
* Load BSON object with specified 'oid'.
* @param oid
* @return BSON object if exists otherwise return NULL.
*/
-EJDB_EXPORT bson* ejdbloadbson(EJCOLL* coll, const bson_oid_t* oid);
+EJDB_EXPORT bson* ejdbloadbson(EJCOLL *coll, const bson_oid_t *oid);
/**
* Create query object.