Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

addToSet,unset update modifiers

  • Loading branch information...
commit d1c7b4eb0d587ac44c37b630110b84a4216350be 1 parent 212a439
@SergejJurecko authored
Showing with 8 additions and 0 deletions.
  1. +2 −0  mongoapi.erl
  2. +6 −0 mongodb.erl
View
2  mongoapi.erl
@@ -78,6 +78,8 @@ save(Rec) ->
% update([{#mydoc.name, "docname"}], #mydoc{tags = {push, "lamer"}}, [])
% update([{#mydoc.name, "docname"}], #mydoc{tags = {pushAll, ["dumbass","jackass"]}}, [upsert])
% update([{#mydoc.name, "docname"}], #mydoc{tags = {pullAll, ["dumbass","jackass"]}}, [upsert])
+% update([{#mydoc.name,"ime"}],#mydoc{i = {addToSet,{array,[1,2,3,4]}}},[upsert])
+% update([{#mydoc.name,"ime"}],#mydoc{i = {addToSet,10}}},[upsert]).
% and so on.
% modifier list: inc, set, push, pushAll, pop, pull, pullAll
% Flags can be: [upsert,multi]
View
6 mongodb.erl
@@ -1169,6 +1169,8 @@ encode_element({Name, {inc, Val}}) ->
encode_element({<<"$inc">>, [{Name, Val}]});
encode_element({Name, {set, Val}}) ->
encode_element({<<"$set">>, [{Name, Val}]});
+encode_element({Name, {unset, Val}}) ->
+ encode_element({<<"$unset">>, [{Name, Val}]});
encode_element({Name, {push, Val}}) ->
encode_element({<<"$push">>, [{Name, Val}]});
encode_element({Name, {pushAll, Val}}) ->
@@ -1179,6 +1181,10 @@ encode_element({Name, {pull, Val}}) ->
encode_element({<<"$pull">>, [{Name, Val}]});
encode_element({Name, {pullAll, Val}}) ->
encode_element({<<"$pullAll">>, [{Name, {array, Val}}]});
+encode_element({Name, {addToSet, {array,Val}}}) ->
+ encode_element({<<"$addToSet">>, [{Name, [{<<"$each">>, {array, Val}}]}]});
+encode_element({Name, {addToSet, Val}}) ->
+ encode_element({<<"$addToSet">>, [{Name, Val}]});
encode_element({Name, {gt, Val}}) ->
encode_element({Name, [{<<"$gt">>, Val}]});
encode_element({Name, {lt, Val}}) ->
Please sign in to comment.
Something went wrong with that request. Please try again.