Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Insert should not behave like upsert #52

Open
5 tasks
will123195 opened this issue Apr 17, 2016 · 0 comments
Open
5 tasks

Insert should not behave like upsert #52

will123195 opened this issue Apr 17, 2016 · 0 comments

Comments

@will123195
Copy link
Owner

will123195 commented Apr 17, 2016

Currently, Table.insert() is an alias of Table.save() which does an upsert.

The API should be changed to this:

  • Table.insert(data) should fail if the primary key already exists.
    • db.table.create().set(data).save({insert: true})
  • Table.upsert(data) alias for Table.save(data) but disallow update and insert options
  • Table.create(data) factory method to create a new row to be saved/persisted later
  • row.save(opts) save the changes to this row and do a recursive upsert of nested tables
    • opts.insert: error if primary key already exists
    • opts.update: error if primary key doesn't exist
  • row.update(data)
    • row.set(data).save({update: true})
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant