Skip to content

Commit

Permalink
fix(create): native vs sql.js last object handling
Browse files Browse the repository at this point in the history
  • Loading branch information
citycide committed Feb 4, 2017
1 parent 06df94f commit 06cfca0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ export function findLastObject (model, object) {
? model.ctx.knex('sqlite_sequence').first('seq').where({ name: model.name })
: model.ctx.knex(model.name).first().where({ [key]: object[key] })

return runQuery(model.ctx, query, true)
.then(res => hasIncrements ? model.findOne({ [key]: res[0].seq }) : res)
return runQuery(model.ctx, query, true).then(res => {
res = model.ctx.isNative ? res : res[0]
return hasIncrements ? model.findOne({ [key]: res.seq }) : res
})
}

function findKey (schema) {
Expand Down

0 comments on commit 06cfca0

Please sign in to comment.