@oridune/epic-odm
Advanced tools
Comparing version 1.0.17 to 1.0.18
{ | ||
"name": "@oridune/epic-odm", | ||
"version": "1.0.17", | ||
"version": "1.0.18", | ||
"description": "Install 1 ODM and code once with any database driver.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -64,16 +64,16 @@ "use strict"; | ||
async _create(connection, command, options) { | ||
// Create insert function | ||
const InsertItems = async (payload) => { | ||
// Insertables | ||
const Insertables = payload.filter((_) => !_._id); | ||
// Create items function | ||
const CreateItems = async (payload) => { | ||
// Collect Insertables | ||
// Validate Insertables before create | ||
const Insertables = await options.database["validateSchema"](command.model, payload.filter((_) => !_._id), { | ||
fieldsList: options.project.getFieldsList(), | ||
mode: "create", | ||
}); | ||
return (Insertables.length | ||
? await options.database["resolveSchema"](command.model, await this.create(connection, command.model, payload)) | ||
? await options.database["resolveSchema"](command.model, await this.create(connection, command.model, Insertables)) | ||
: await options.database["resolveSchema"](command.model, payload)).map((item) => command.model.new(item)); | ||
}; | ||
// Validate payload before insert | ||
// Insert Items | ||
const Items = await InsertItems(await options.database["validateSchema"](command.model, command.payload, { | ||
fieldsList: options.project.getFieldsList(), | ||
mode: "create", | ||
})); | ||
// Create Items | ||
const Items = await CreateItems(command.payload); | ||
// Get Model Options | ||
@@ -80,0 +80,0 @@ const ModelOptions = (0, model_1.getModelOptions)(command.model); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94948