View Source MongoAgile.Queries.Helper.Update (mongo_agile v0.8.1-rc)
Info origin: https://docs.mongodb.com/manual/reference/operator/update/
Name Description $currentDate Sets the value of a field to current date, either as a Date or a Timestamp. $inc Increments the value of the field by the specified amount. $min Only updates the field if the specified value is less than the existing field value. $max Only updates the field if the specified value is greater than the existing field value. $mul Multiplies the value of the field by the specified amount. $rename Renames a field. $set Sets the value of a field in a document. $setOnInsert Sets the value of a field if an update results in an insert of a document. Has no effect on update operations that modify existing documents. $unset Removes the specified field from a document.
Link to this section Summary
Functions
Get $addToSet value of map type.
Get $bit value of map type.
Get $currentDate value of map type.
Get $inc value of map type.
Get $max value of map type.
Get $min value of map type.
Get $mul value of map type.
Get $pop value of map type.
Get $pull value of map type.
Get $pullAll value of map type.
Get $push value of map type.
Get $rename value of map type.
Get $set value of map type.
Get $setOnInsert value of map type.
Get $unset value of map type.
It´s will return true, if the map follow the schema.
Let decode json to Object. Checking every type following the schema.
Let decode json and mut a existing object . Checking every type following the schema.
Intenal it´s using the method put/2
.
Let encode object to Json.
mut the value of $addToSet field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $bit field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $currentDate field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $inc field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $max field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $min field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $mul field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $pop field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $pull field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $pullAll field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $push field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $rename field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $set field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $setOnInsert field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of $unset field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
This method only create a new simple map %{}. Yes.
Put a new value in each field of the update map, in the field of the object.
Put a new value in each field of the update map, in the field of the object.
Put a new value in $addToSet field. Before of update the valor will be check it.
Put a new value in $bit field. Before of update the valor will be check it.
Put a new value in $currentDate field. Before of update the valor will be check it.
Put a new value in $inc field. Before of update the valor will be check it.
Put a new value in $max field. Before of update the valor will be check it.
Put a new value in $min field. Before of update the valor will be check it.
Put a new value in $mul field. Before of update the valor will be check it.
Put a new value in $pop field. Before of update the valor will be check it.
Put a new value in $pull field. Before of update the valor will be check it.
Put a new value in $pullAll field. Before of update the valor will be check it.
Put a new value in $push field. Before of update the valor will be check it.
Put a new value in $rename field. Before of update the valor will be check it.
Put a new value in $set field. Before of update the valor will be check it.
Put a new value in $setOnInsert field. Before of update the valor will be check it.
Put a new value in $unset field. Before of update the valor will be check it.
Put a new value in each field of the update map, in the field of the object only if exist the field in the schema (ifmatch)
Put a new value in each field of the update map, in the field of the object only if exist the field in the schema (ifmatch)
The Schema is: %{"$addToSet" => :map, "$bit" => :map, "$currentDate" => :map, "$inc" => :map, "$max" => :map, "$min" => :map, "$mul" => :map, "$pop" => :map, "$pull" => :map, "$pullAll" => :map, "$push" => :map, "$rename" => :map, "$set" => :map, "$setOnInsert" => :map, "$unset" => :map}
Get the module of type by name
Say if the schema use Atomize mode.
Map of types
Link to this section Functions
Get $addToSet value of map type.
Get $bit value of map type.
Get $currentDate value of map type.
Get $inc value of map type.
Get $max value of map type.
Get $min value of map type.
Get $mul value of map type.
Get $pop value of map type.
Get $pull value of map type.
Get $pullAll value of map type.
Get $push value of map type.
Get $rename value of map type.
Get $set value of map type.
Get $setOnInsert value of map type.
Get $unset value of map type.
It´s will return true, if the map follow the schema.
Let decode json to Object. Checking every type following the schema.
Note: This method use Jason library.
@spec json_decode( any(), binary() | maybe_improper_list( binary() | maybe_improper_list(any(), binary() | []) | byte(), binary() | [] ) ) :: any()
Let decode json and mut a existing object . Checking every type following the schema.
Intenal it´s using the method put/2
.
Note: This method use Jason library.
parameters
Parameters
- mapa: Object
- json: Json object
Let encode object to Json.
Note: This method use Jason library.
mut the value of $addToSet field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $addToSet is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$addToSet(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$addToSet(obj)
%{example_field: 11}
mut the value of $bit field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $bit is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$bit(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$bit(obj)
%{example_field: 11}
mut the value of $currentDate field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $currentDate is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$currentDate(fn(_old)-> %{ field0: 0, field1: 1} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$currentDate(obj)
%{ field0: 0, field1: 1}
mut the value of $inc field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $inc is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$inc(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$inc(obj)
%{example_field: 11}
mut the value of $max field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $max is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$max(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$max(obj)
%{example_field: 11}
mut the value of $min field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $min is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$min(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$min(obj)
%{example_field: 11}
mut the value of $mul field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $mul is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$mul(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$mul(obj)
%{example_field: 11}
mut the value of $pop field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $pop is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$pop(fn(_old)-> %{ field0: 0, field1: 1} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$pop(obj)
%{ field0: 0, field1: 1}
mut the value of $pull field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $pull is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$pull(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$pull(obj)
%{example_field: 11}
mut the value of $pullAll field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $pullAll is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$pullAll(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$pullAll(obj)
%{example_field: 11}
mut the value of $push field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $push is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$push(fn(_old)-> %{ field0: 0, field1: 1} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$push(obj)
%{ field0: 0, field1: 1}
mut the value of $rename field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $rename is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$rename(fn(_old)-> %{ field0: 0, field1: 1} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$rename(obj)
%{ field0: 0, field1: 1}
mut the value of $set field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $set is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$set(fn(_old)-> %{example_field: 11} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$set(obj)
%{example_field: 11}
mut the value of $setOnInsert field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $setOnInsert is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$setOnInsert(fn(_old)-> %{ field0: 0, field1: 1} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$setOnInsert(obj)
%{ field0: 0, field1: 1}
mut the value of $unset field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that $unset is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.mut_$unset(fn(_old)-> %{ field0: 0, field1: 1} end)
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$unset(obj)
%{ field0: 0, field1: 1}
This method only create a new simple map %{}. Yes.
Because the idea it´s the data structure will be independent of MapSchema but the module will have the schema that the maps should be follow.
example
Example:
iex>Elixir.MongoAgile.Queries.Helper.Update.new()
%{}
Put a new value in each field of the update map, in the field of the object.
But before of update the values always will be check the type.
If a field dont exist in the schema throw exception. (If you need be less strict you can use put_ifmatch/1
or put_ifmatch/2
)
Put a new value in each field of the update map, in the field of the object.
But before of update the values always will be check the type.
If a field dont exist in the schema throw exception. (If you need be less strict you can use put_ifmatch/1
or put_ifmatch/2
)
Put a new value in $addToSet field. Before of update the valor will be check it.
Remember that $addToSet is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$addToSet(%{ field0: 0, field1: 1})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$addToSet(obj)
%{ field0: 0, field1: 1}
Put a new value in $bit field. Before of update the valor will be check it.
Remember that $bit is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$bit(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$bit(obj)
%{example_field: 11}
Put a new value in $currentDate field. Before of update the valor will be check it.
Remember that $currentDate is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$currentDate(%{ field0: 0, field1: 1})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$currentDate(obj)
%{ field0: 0, field1: 1}
Put a new value in $inc field. Before of update the valor will be check it.
Remember that $inc is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$inc(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$inc(obj)
%{example_field: 11}
Put a new value in $max field. Before of update the valor will be check it.
Remember that $max is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$max(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$max(obj)
%{example_field: 11}
Put a new value in $min field. Before of update the valor will be check it.
Remember that $min is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$min(%{ field0: 0, field1: 1})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$min(obj)
%{ field0: 0, field1: 1}
Put a new value in $mul field. Before of update the valor will be check it.
Remember that $mul is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$mul(%{ field0: 0, field1: 1})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$mul(obj)
%{ field0: 0, field1: 1}
Put a new value in $pop field. Before of update the valor will be check it.
Remember that $pop is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$pop(%{ field0: 0, field1: 1})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$pop(obj)
%{ field0: 0, field1: 1}
Put a new value in $pull field. Before of update the valor will be check it.
Remember that $pull is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$pull(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$pull(obj)
%{example_field: 11}
Put a new value in $pullAll field. Before of update the valor will be check it.
Remember that $pullAll is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$pullAll(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$pullAll(obj)
%{example_field: 11}
Put a new value in $push field. Before of update the valor will be check it.
Remember that $push is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$push(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$push(obj)
%{example_field: 11}
Put a new value in $rename field. Before of update the valor will be check it.
Remember that $rename is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$rename(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$rename(obj)
%{example_field: 11}
Put a new value in $set field. Before of update the valor will be check it.
Remember that $set is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$set(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$set(obj)
%{example_field: 11}
Put a new value in $setOnInsert field. Before of update the valor will be check it.
Remember that $setOnInsert is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$setOnInsert(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$setOnInsert(obj)
%{example_field: 11}
Put a new value in $unset field. Before of update the valor will be check it.
Remember that $unset is map type.
example
Example:
iex>obj = Elixir.MongoAgile.Queries.Helper.Update.new()
...> |> Elixir.MongoAgile.Queries.Helper.Update.put_$unset(%{example_field: 11})
iex> Elixir.MongoAgile.Queries.Helper.Update.get_$unset(obj)
%{example_field: 11}
Put a new value in each field of the update map, in the field of the object only if exist the field in the schema (ifmatch)
But before of update the values always will be check the type.
Put a new value in each field of the update map, in the field of the object only if exist the field in the schema (ifmatch)
But before of update the values always will be check the type.
The Schema is: %{"$addToSet" => :map, "$bit" => :map, "$currentDate" => :map, "$inc" => :map, "$max" => :map, "$min" => :map, "$mul" => :map, "$pop" => :map, "$pull" => :map, "$pullAll" => :map, "$push" => :map, "$rename" => :map, "$set" => :map, "$setOnInsert" => :map, "$unset" => :map}
Get the module of type by name
Say if the schema use Atomize mode.
Map of types