@startupjs/sharedb-schema
Advanced tools
Comparing version 0.32.1 to 0.33.0-alpha.4
@@ -10,2 +10,3 @@ const ZSchema = require('z-schema') | ||
this.backend = backend | ||
this.model = backend.createModel() | ||
this.options = options | ||
@@ -25,2 +26,3 @@ this.schemas = schemas | ||
snapshot: { data: newDoc }, | ||
id: docId, | ||
collection, | ||
@@ -40,4 +42,12 @@ op: opData | ||
const rootSchema = this.schemas[collection] | ||
let rootSchema = this.schemas[collection] | ||
if (rootSchema.factory) { | ||
const $doc = this.model._scope(`${collection}.${docId}`) | ||
await $doc.subscribe() | ||
// get model from factory like in @startupjs/orm: https://github.com/startupjs/startupjs/blob/master/packages/orm/lib/index.js#L77 | ||
const factoryModel = rootSchema($doc, this.model) | ||
rootSchema = { type: 'object', properties: factoryModel.constructor.schema } | ||
} | ||
if (!rootSchema) { | ||
@@ -102,3 +112,3 @@ // throw error if current collenction have no schema | ||
this.validator.validate(snapshotData, this.schemas[collectionName]) | ||
this.validator.validate(snapshotData, schema) | ||
const _errors = this.validator.getLastErrors() | ||
@@ -105,0 +115,0 @@ |
{ | ||
"name": "@startupjs/sharedb-schema", | ||
"version": "0.32.1", | ||
"version": "0.33.0-alpha.4", | ||
"description": "Racer plugin for schema validation module for ShareDB", | ||
@@ -33,3 +33,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "d56aff2fb9adcc686a08f037e20ff5f67a858336" | ||
"gitHead": "57947aca55fe27bb09e4d13287d3ad1425c12049" | ||
} |
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
27064
818