Closed arthurfranca closed 4 years ago
At the moment there is no easy way to do this.
But instead of __exists = true
use _exists()
.
Thx, _exists()
works.
Just setting __exists = true
seems to keep object.changes
with many entries so that it later updates many unwanted properties.
edit: For those that might have same issue, I would like to add that doing Model.where({ id: rows.map(r => r.id) })
would lose row ordering
Was looking at the code but couldn't figure out a good way of transforming the result set from
knex/Model.raw(query).then(result => result.rows)
into regular OpenRecord record objects.The important thing is that i can't just do new Model(json), because i dont want a future .save() or .update() to end up creating new records on database, but just updating them (if primary keys are present).
Best i could do was the following:
But i'm afraid of letting my code rely on
__exists
which is an internal property.Is there a recommended way of doing it?