@travetto/model
Advanced tools
Comparing version 0.3.8 to 0.3.9
@@ -10,8 +10,8 @@ { | ||
"dependencies": { | ||
"@travetto/di": "^0.3.5", | ||
"@travetto/schema": "^0.3.6" | ||
"@travetto/di": "^0.3.6", | ||
"@travetto/schema": "^0.3.7" | ||
}, | ||
"description": "Datastore abstraction for CRUD operations with advanced query support.", | ||
"devDependencies": { | ||
"@travetto/test": "^0.3.5" | ||
"@travetto/test": "^0.3.6" | ||
}, | ||
@@ -36,4 +36,4 @@ "optionalExtensionDependencies": { | ||
}, | ||
"version": "0.3.8", | ||
"gitHead": "b4f46ddcd29fe1e3fafbd1da75cd5530815f6d39" | ||
"version": "0.3.9", | ||
"gitHead": "a97a54d48f681c8a3c265803ab1f8d8da1690f39" | ||
} |
@@ -19,12 +19,4 @@ import { SchemaRegistry, SchemaChangeEvent } from '@travetto/schema'; | ||
} | ||
onSchemaChange(cb: (x: SchemaChangeEvent) => void) { | ||
SchemaRegistry.onSchemaChange((e) => { | ||
if (this.has(e.cls)) { | ||
cb(e); | ||
} | ||
}); | ||
} | ||
} | ||
export const ModelRegistry = new $ModelRegistry(); |
import { Class } from '@travetto/registry'; | ||
import { BindUtil, SchemaValidator, DEFAULT_VIEW } from '@travetto/schema'; | ||
import { BindUtil, SchemaValidator, DEFAULT_VIEW, SchemaRegistry } from '@travetto/schema'; | ||
import { Injectable } from '@travetto/di'; | ||
@@ -35,3 +35,7 @@ import { Env, Util } from '@travetto/base'; | ||
if (this.source.onSchemaChange) { | ||
ModelRegistry.onSchemaChange(this.source.onSchemaChange.bind(this.source)); | ||
SchemaRegistry.onSchemaChange(event => { | ||
if (ModelRegistry.has(event.cls)) { | ||
this.source.onSchemaChange!(event); | ||
} | ||
}); | ||
} | ||
@@ -87,7 +91,7 @@ if (this.source.onChange) { | ||
/** Executes a raw query against the model space */ | ||
async query<T extends ModelCore, U = T>(cls: Class<T>, query: Query<T>) { | ||
async query<T extends ModelCore, U = T>(cls: Class<T>, query: Query<T>): Promise<U[]> { | ||
this.queryService.verify(cls, query); | ||
const res = await this.source.query<T, U>(cls, query); | ||
return res.map(o => this.postLoad(cls, o as any as T)); | ||
return res.map(o => this.postLoad(cls, o as any as T) as any as U); | ||
} | ||
@@ -94,0 +98,0 @@ |
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
39768
840
Updated@travetto/di@^0.3.6
Updated@travetto/schema@^0.3.7