dflourusso / expo-sqlite-orm

Expo SQLite ORM
132 stars 34 forks source link

Proposal to implement OR operation #66

Open eznix86 opened 5 months ago

eznix86 commented 5 months ago

Currently, keys are extracted from the where statement which intrinsically creates an AND statement.

To prevent breaking changes, the current behaviour will stay the same, but we can consider to have custom operators to extend the where functionally.

Introducing $ operators.

Theses operators can extend the functionally within where clause.

Example:

qb.query({
  columns: 'id, name, status',
  where: {
    status: { equals: 'finished' },
    $or: [
      { name: { equals: 'Alice' } },
      { city: { equals: 'New York' } }
    ]
  }
})

This will be parsed to become:

[!NOTE] Between status and $or, the operation AND stays applicable. Example below:

select id,name,status from users where status AND ( name = "alice" OR city = "New York" )

This can resolve #43

This can open opportunity to $and