From 06cfca036139408abaf4a157cc51e4b65b2b7194 Mon Sep 17 00:00:00 2001 From: citycide Date: Fri, 3 Feb 2017 23:51:40 -0600 Subject: [PATCH] fix(create): native vs `sql.js` last object handling --- src/helpers.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/helpers.js b/src/helpers.js index d778e90..3720196 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -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) {