From 50a831cd0eff691aa989a728d86c16870bf5b0a8 Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Sat, 30 Jan 2016 10:06:25 -0700 Subject: [PATCH] Remove array check in create. Since Mongoose has bulk support, and we already implemented array support in events, this will keep hooks from running for each item in the array. --- src/service.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/service.js b/src/service.js index 40f2b119..c7b6e1df 100644 --- a/src/service.js +++ b/src/service.js @@ -39,7 +39,7 @@ class Service { // $select uses a specific find syntax, so it has to come first. if (filters.$select && filters.$select.length) { let fields = {}; - + for (let key of filters.$select) { fields[key] = 1; } @@ -100,11 +100,7 @@ class Service { }).catch(errorHandler); } - create(data, params) { - if(Array.isArray(data)) { - return Promise.all(data.map(current => this.create(current, params))); - } - + create(data) { return this.Model.create(data).catch(errorHandler); } @@ -195,4 +191,4 @@ export default function init(options) { return new Service(options); } -init.Service = Service; \ No newline at end of file +init.Service = Service;