#11
authoradam <anton@adamansky.com>
Fri, 14 Dec 2012 05:31:21 +0000 (12:31 +0700)
committeradam <anton@adamansky.com>
Fri, 14 Dec 2012 05:31:21 +0000 (12:31 +0700)
Changelog
README.md
node/ejdb.js
tcejdb/ejdb.h
tcejdb/ejdb_private.h

index f77806d..4f63ad3 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,7 @@
+2012-12-14 Anton Adamansky. <adamansky@gmail.com>
+    * Added `$addToSet` and `$pull` operations.
+    - Release 1.0.26
+
 2012-12-04 Anton Adamansky. <adamansky@gmail.com>
     * Allows multiple matching conditions for single query field. Eg: {'age' : {'$lt' : '60', '$gt' : '30'}}
     - Release 1.0.25
index 9fa3dcb..cde7ec3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -271,13 +271,19 @@ EJDB queries inspired by MongoDB (mongodb.org) and follows same philosophy.
           -  {'name' : {'$icase' : {'$in' : ['tHéâtre - театр', 'heLLo WorlD']}}}
            For case insensitive matching you can create special type of string index.
 
-    Queries can be used to update records:
-      `$set` Field set operation.
-           - {some fields for selection, '$set' : {'field1' : {obj}, ...,  'field1' : {obj}}}
-      `$inc` Increment operation. Only number types are supported.
-           - {some fields for selection, '$inc' : {'field1' : number, ...,  'field1' : {number}}
-      `$dropall` In-place record removal operation.
-           - {some fields for selection, '$dropall' : true}
+      - Queries can be used to update records:
+
+        $set Field set operation.
+            - {.., '$set' : {'field1' : val1, 'fieldN' : valN}}
+        $inc Increment operation. Only number types are supported.
+            - {.., '$inc' : {'field1' : number, ...,  'field1' : number}
+        $dropall In-place record removal operation.
+            - {.., '$dropall' : true}
+        $addToSet Atomically adds value to the array only if its not in the array already.
+                    If containing array is missing it will be created.
+            - {.., '$addToSet' : {'json.field.path' : val1, 'json.field.pathN' : valN, ...}}
+        $pull - Atomically removes all occurrences of value from field, if field is an array.
+            - {.., '$pull' : {'json.field.path' : val1, 'json.field.pathN' : valN, ...}}
 
     NOTE: It is better to execute update queries with `$onlycount=true` hint flag
          or use the special `update()` method to avoid unnecessarily rows fetching.
@@ -367,6 +373,11 @@ Convenient method to execute update queries.
     - {some fields for selection, '$inc' : {'field1' : number, ...,  'field1' : {number}}
  * `$dropall` In-place record removal operation.
     - {some fields for selection, '$dropall' : true}
+ * `$addToSet` Atomically adds value to the array only if its not in the array already.
+               If containing array is missing it will be created.
+    - {.., '$addToSet' : {'json.field.path' : val1, 'json.field.pathN' : valN, ...}}
+ * `$pull` Atomically removes all occurrences of value from field, if field is an array.
+    - {.., '$pull' : {'json.field.path' : val1, 'json.field.pathN' : valN, ...}}
 
 Call variations of update():
 
index c6a38b2..87ad3eb 100644 (file)
@@ -202,14 +202,19 @@ EJDB.prototype.remove = function(cname, oid, cb) {
  *          -    {'name' : {'$icase' : {'$in' : ['tHéâtre - театр', 'heLLo WorlD']}}}
  *          For case insensitive matching you can create special type of string index.
  *
- *  - Queries can be used to update records
- *
- *      `$set` Field set operation.
- *          - {some fields for selection, '$set' : {'field1' : {obj}, ...,  'field1' : {obj}}}
- *      `$inc` Increment operation. Only number types are supported.
- *          - {some fields for selection, '$inc' : {'field1' : number, ...,  'field1' : {number}}
- *      `$dropall` In-place record removal operation.
- *          - {some fields for selection, '$dropall' : true}
+ *  - Queries can be used to update records:
+ *
+ *      $set Field set operation.
+ *          - {.., '$set' : {'field1' : val1, 'fieldN' : valN}}
+ *      $inc Increment operation. Only number types are supported.
+ *          - {.., '$inc' : {'field1' : number, ...,  'field1' : number}
+ *      $dropall In-place record removal operation.
+ *          - {.., '$dropall' : true}
+ *      $addToSet Atomically adds value to the array only if its not in the array already.
+ *                  If containing array is missing it will be created.
+ *          - {.., '$addToSet' : {'json.field.path' : val1, 'json.field.pathN' : valN, ...}}
+ *      $pull Atomically removes all occurrences of value from field, if field is an array.
+ *          - {.., '$pull' : {'json.field.path' : val1, 'json.field.pathN' : valN, ...}}
  *
  *  NOTE: It is better to execute update queries with `$onlycount=true` hint flag
  *        or use the special `update()` method to avoid unnecessarily data fetching.
index 4b19f2f..646af36 100644 (file)
@@ -242,14 +242,19 @@ EJDB_EXPORT bson* ejdbloadbson(EJCOLL *coll, const bson_oid_t *oid);
  *          -    {'name' : {'$icase' : {'$in' : ['théâtre - театр', 'hello world']}}}
  *          For case insensitive matching you can create special index of type: `JBIDXISTR`
  *
- *  - Queries can be used to update records
+ *  - Queries can be used to update records:
  *
- *      `$set` Field set operation.
- *          - {some fields for selection, '$set' : {'field1' : {obj}, ...,  'field1' : {obj}}}
- *      `$inc` Increment operation. Only number types are supported.
- *          - {some fields for selection, '$inc' : {'field1' : number, ...,  'field1' : {number}}
- *      `$dropall` In-place record removal operation.
- *          - {some fields for selection, '$dropall' : true}
+ *      $set Field set operation.
+ *          - {.., '$set' : {'field1' : val1, 'fieldN' : valN}}
+ *      $inc Increment operation. Only number types are supported.
+ *          - {.., '$inc' : {'field1' : number, ...,  'field1' : number}
+ *      $dropall In-place record removal operation.
+ *          - {.., '$dropall' : true}
+ *      $addToSet Atomically adds value to the array only if its not in the array already.
+ *                  If containing array is missing it will be created.
+ *          - {.., '$addToSet' : {'json.field.path' : val1, 'json.field.pathN' : valN, ...}}
+ *      $pull  Atomically removes all occurrences of value from field, if field is an array.
+ *          - {.., '$pull' : {'json.field.path' : val1, 'json.field.pathN' : valN, ...}}
  *
  *
  *  NOTE: It is better to execute update queries with `JBQRYCOUNT`
index 9fc2f26..700f8f4 100644 (file)
@@ -56,7 +56,7 @@ enum { /**> Query field flags */
 
     EJCONDSET = 1 << 10, /**> $set Set field update operation */
     EJCONDINC = 1 << 11, /**> $inc Inc field update operation */
-    EJCONDADDSET = 1 << 12, /**> $addToSet Adds value to the array only if its not in the array already */
+    EJCONDADDSET = 1 << 12, /**> $addToSet Adds value to the array only if its not in the array already */
     EJCONDPULL = 1 << 13 /**> $pull Removes all occurrences of value from field, if field is an array */
 };