event-engine / php-document-store Goto Github PK
View Code? Open in Web Editor NEWEvent Engine PHP Document Store Contract
Home Page: https://event-engine.io
License: MIT License
Event Engine PHP Document Store Contract
Home Page: https://event-engine.io
License: MIT License
A way to count (filtered) documents without actually loading them would be useful: public function countDocs(string $collectionName, Filter $filter): int
We should define a standard format for using the InArrayFilter
. The example shown in this comment: #4 (comment) works for Postgres, but might not work for mongoDB.
We need to add support for JSON flags to ensure correct behavior e.g. treat an empty array as object. See this test.
It would be useful, if Index defines a name()
method. This allows only one instanceof
check e.g. in dropIndex
to get the name of the index, instead of checking for FieldIndex
and MutliFieldIndex
.
Given a document inside the document store with the following content:
{
"state" : {
"key1" : "value1",
"key2" : [{
"subkey" : "value 1"
}, {
"subkey" : "value 2"
}],
"key3" : "value3"
}
}
How can I retrieve that document from the document store using value 2
for subkey
inside key2
?
For key1
and key3
i'd use the following code:
$filter = new EqFilter('state.key1', 'value1');
$filter = new EqFilter('state.key3', 'value3');
But how would I go for value 2
?
I tried the following to no avail:
$filter = new EqFilter('state.key2.subkey', 'value 1');
$filter = new EqFilter('state.key2.[].subkey', 'value 1');
What am I missing? Do I by chance need to use the ArrayFilter
instead?
With #21 we will have a BC break. So we should also think about an interface to allow to return the raw json data. Something like getDocRaw
without json_decode
.
Assuming the following:
$this->documentStore->updateDoc(
$collection,
$event->get(Payload::USER_ID),
[
Payload::USER_VALIDATIONS => [
$event->get(Payload::USER_EMAIL_ADDRESS) => $event->createdAt(),
],
],
);
The InMemoryDocumentStore
would merge the Payload::USER_VALIDATIONS
arrays recursively, adding additional values. This provides no way of removing a nested key. There is even a test to enforce this behaviour: https://github.com/event-engine/php-document-store/blob/1e980c8e8e3f7b48428740e109692440dffa3a2b/tests/InMemoryDocumentStoreTest.php#L88-112
Further, the event-engine/php-postgres-document-store
handles this differently, where merges are NOT recursive: https://github.com/event-engine/php-postgres-document-store/blob/e9721e21f42a648a79eb9865b5656c6949bf1c42/src/PostgresDocumentStore.php#L366
For more on how the ||
operator is used: https://www.postgresql.org/docs/13/functions-json.html
I have submitted the following PRs for changes:
event-engine/php-postgres-document-store
to confirm that associative arrays are not merged recursively (event-engine/php-postgres-document-store#15).InMemoryDocumentStore
to conform to the behaviour of event-engine/php-postgres-document-store
(#18).A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.