marioreggiori / objectdb

Persistent embedded document-oriented NoSQL database for Dart and Flutter.
https://pub.dev/packages/objectdb
MIT License
190 stars 21 forks source link

Allow array types to be stored #43

Closed fhuonder closed 3 years ago

fhuonder commented 4 years ago

Hi,

According to rfc7159 (https://tools.ietf.org/html/rfc7159) a JSON can also have an array as top level element

[
 {...},
 {...},
 {...}
]

Because the methods of the objectdb are of type Map<String, dynamic> (for insert and update) it is not possible to pass a List to be stored. Would be great if this will be possible in a future version.

Regards, Florian

marioreggiori commented 4 years ago

Hi @fhuonder, currently every entry gets a unique ID that's why arrays at 0 level are not allowed. You could do something like this: {"_" : ["some", "data"] } Unfortunately querying arrays is very limited at the moment. I guess it wouldn't be very difficult to implement but if it exists users of the lib would expect better querying options. That's why I think it should be implemented afterwards.

Greetings, Mario

marioreggiori commented 4 years ago

Hi @fhuonder, I've just added basic array querying, and it would be great if you could test the changes. There is a prerelease at pub.dev and you can check out the syntax in this test file. Feedback is greatly appreciated!

Greetings, Mario

fhuonder commented 4 years ago

Hi Mario,

I can have a look. I hope that it fits into my schedule next week. I'll come back to you.

Regards, Florian

fhuonder commented 4 years ago

Hi Mario,

I had a quick look and for me it looks good. For my case this would work like this.

Regards, Florian