Releases: TCB13/sequel-mongo-php
Releases · TCB13/sequel-mongo-php
Pull From Everywhere
Improved ArrayPull
: pull strings from arrays or objects matching conditions from arrays of objects.
Remove individual value from array:
new ArrayPull("list", "user.123")
Remove multiple values from array:
new ArrayPull("list", ["user.123", "user.456"])
Remove objects from array of objects based on condition:
new ArrayPull("list", ["id" => ["user.123", "user.456"]])
new ArrayPull("list", ["id" => "user.123"])
new ArrayPull("list", ["id" => "user.123", "name" => "joe"])
Identify
Push you all!
- Add multiple items to an array at once using
ArrayPush
.
Count Better
- Improve QueryBuilder::count().
Custom Pipelines
- Run queries with your own custom pipelines with the QueryBuilder::pipeline() method;
- More PSR.
ArrayLength
- Use the
ArrayLength
special function inselect()
and filter your results by the obtained length withwhere()
.
Unwind Yourself!
Adds unwind(string $path, ?string $includeArrayIndex = null, bool $preserveNullAndEmptyArrays = false)
Pull Away!
ArrayPull
: Now optionally accepts an array of values instead of just one for the same property. Example:
$tokensToRemove = ["token1", "token2", "token3"];
$result = (new QueryBuilder())->collection("Users")
->where("active", true)
->update([new ArrayPull("pushtokens", ["token" => $tokensToRemove])]);
From any model with a pushtokens
property that is an array of objects containing a token
property, remove entries that are in $tokensToRemove
.
Objectify MongoDB
New features:
- Direct Insert / Update of objects into MongoDB is now possible. Objects must implement
MongoDB\BSON\{Serializable, Unserializable}
interfaces. This allows you to implement your own custom serialization/deserialization operations.
Improvements and bug fixes: QueryBuilder::deserializeResult()
is now public. Can be used instead of::toArray()
or::toObject()
to get results deserialized as you would like. Read http://php.net/manual/en/mongodb.persistence.deserialization.php for more info;- More PSR.