appy-one / acebase

A fast, low memory, transactional, index & query enabled NoSQL database engine and server for node.js and browser with realtime data change notifications
MIT License
481 stars 27 forks source link

filter on nested data and IN operator for string type #235

Closed fabriciovasc closed 1 year ago

fabriciovasc commented 1 year ago

I had two problems with query filter of collection. First example, I have nested object with 3 properties and I need to filter them.

const data = [
  { id: 1, owner: { user: 'xxx', friend: 'xxx' } }
  { id: 2, owner: { user: 'yyy', friend: 'yyy' } }
]

Based on the docs and issue https://github.com/appy-one/acebase/issues/62 that should look something like:

db.query(collection).filter('owner/user', '==', 'xxx')

But after the query I don't have any values. Is there another way to filter nested objects?


Second example, I have string property which can have multiple values and I try to filter using IN operator. That should look something like:

const data = [
  { id: 1, status: 'SYNCED' }
  { id: 2, status: 'DISABLED' }
]

db.query(collection).filter('status', 'in', ['SYNCED', 'DISABLED'])

But after the query I don't have any values. Is there another way to filter string property with multiple values? Something like MongoDB query with $in operator