expo-sqlite-orm icon indicating copy to clipboard operation
expo-sqlite-orm copied to clipboard

column validations are too strict

Open realjjaveweb opened this issue 3 years ago • 1 comments

The column validation is too strict in what can go in and out.

Out:

await SomeModel.query({
    columns: 'COUNT(*)',
});

This returns EMPTY results, because obviously there is no known column name, but if there's an "id" column on the model, this works

await SomeModel.query({
    columns: 'COUNT(*) as id',
});

In If there are data missing on save, they are added anyways, but usually during update, you just want to update some columns, I would expect from .save() when primary key is present, just update columns available.

realjjaveweb avatar Mar 13 '22 00:03 realjjaveweb

I think it should remain strict, instead we should have another function similar to prisma:

https://www.prisma.io/docs/orm/prisma-client/queries/aggregation-grouping-summarizing

await SomeModel.aggregate({
  $avg: {
    age: true,
  },
  $count: {
    age: true,
  },
})

Then instead of returning an object of the model, it returns an object of type Aggregate, with avg, and count attributes I talked about new key words there: #66

eznix86 avatar Jan 03 '24 10:01 eznix86