2012-12-14 Anton Adamansky. <adamansky@gmail.com>
* Added `$addToSet` and `$pull` operations.
- - Release 1.0.26
+ - Release 1.0.27
2012-12-04 Anton Adamansky. <adamansky@gmail.com>
* Allows multiple matching conditions for single query field. Eg: {'age' : {'$lt' : '60', '$gt' : '30'}}
{
"name" : "ejdb",
- "version" : "1.0.26",
+ "version" : "1.0.27",
"main" : "node/ejdb.js",
"description" : "EJDB - Embedded JSON Database engine",
"homepage" : "http://ejdb.org",
return rv;
}
+EJDB_EXPORT bool bson_find_merged_array_sets(const void *mbuf, const void *inbuf) {
+ assert(mbuf && inbuf);
+ bool found = false;
+ bson_iterator it, it2;
+ bson_type bt, bt2;
+ bson_iterator_from_buffer(&it, mbuf);
+ while ((bt = bson_iterator_next(&it)) != BSON_EOO) {
+ bson_iterator_from_buffer(&it2, inbuf);
+ bt2 = bson_find_fieldpath_value(bson_iterator_key(&it), &it2);
+ if (bt2 != BSON_ARRAY) {
+ continue;
+ }
+ bson_iterator sit;
+ bson_iterator_subiterator(&it2, &sit);
+ while ((bt2 = bson_iterator_next(&sit)) != BSON_EOO) {
+ if (!bson_compare_it_current(&sit, &it)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ break;
+ }
+ }
+ return found;
+}
+
EJDB_EXPORT bool bson_find_unmerged_array_sets(const void *mbuf, const void *inbuf) {
assert(mbuf && inbuf);
bool allfound = false;
EJDB_EXPORT bson* bson_create_from_buffer2(bson *bs, const void *buf, int bufsz);
EJDB_EXPORT bool bson_find_unmerged_array_sets(const void *mbuf, const void *inbuf);
+EJDB_EXPORT bool bson_find_merged_array_sets(const void *mbuf, const void *inbuf);
EJDB_EXPORT int bson_merge_array_sets(const void *mbuf, const void *inbuf, bool pull, bson *bsout);
if (pullqf) { //$pull
char* inbuf = (bsout.finished) ? bsout.data : bsbuf;
- if (!bson_find_unmerged_array_sets(bson_data(pullqf->updateobj), inbuf)) {
+ if (bson_find_merged_array_sets(bson_data(pullqf->updateobj), inbuf)) {
if (bsout.finished) {
//reinit `bsout`, `inbuf` already points to `bsout.data` and will be freed later
bson_init_size(&bsout, bson_size(&bsout));