@northernv/supermodel
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -42,2 +42,9 @@ const k = require('knex') | ||
}) | ||
it('should return empty array when passed empty array', async () => { | ||
tracker.on('query', (query) => { | ||
throw new Error('cant insert empty array') | ||
}) | ||
const res = await Fake.create([], { db }) | ||
expect(res).toEqual([]) | ||
}) | ||
it('should return a single object when passed object', async () => { | ||
@@ -44,0 +51,0 @@ tracker.on('query', (query) => { |
@@ -109,2 +109,5 @@ const assert = require('assert') | ||
// If we have empty array, just bail | ||
if (inserts.length === 0) return Promise.resolve([]) | ||
const q = knex(this.table).insert(inserts) | ||
@@ -151,3 +154,3 @@ | ||
// This caused problems with an empty update and the collection overriden | ||
// in the model was looking for properties not includes int he query | ||
// in the model was looking for properties not includes in the query | ||
if (isEmpty(properties)) return this.collection(query, opts) | ||
@@ -154,0 +157,0 @@ |
{ | ||
"name": "@northernv/supermodel", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A Base model for Knex", | ||
@@ -10,2 +10,3 @@ "main": "index.js", | ||
"test": "jest", | ||
"test:coverage": "jest --collectCoverage", | ||
"lint": "eslint --quiet ./" | ||
@@ -12,0 +13,0 @@ }, |
Sorry, the diff of this file is not supported yet
26181
695