Permalink
Browse files

addToSet,unset update modifiers

  • Loading branch information...
1 parent 212a439 commit d1c7b4eb0d587ac44c37b630110b84a4216350be @SergejJurecko committed Mar 28, 2010
Showing with 8 additions and 0 deletions.
  1. +2 −0 mongoapi.erl
  2. +6 −0 mongodb.erl
View
@@ -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
@@ -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}}) ->

0 comments on commit d1c7b4e

Please sign in to comment.