graph-common
Version:
Open Graph API core js lib
48 lines (39 loc) • 1.63 kB
text/coffeescript
SchemaManager takes care of schemas and models and their loading
class SchemaManager
constructor: (graph, core_model_mapping) ->
self = @
= graph
= .database
= []
= []
= core_model_mapping
load_core_model: (name, file) ->
model_definition = require(file)
schema = model_definition.schema
methods = model_definition.methods
init_core_model: (done) ->
for core_model, file of
done()
reload: () ->
Schema =
Schema.find({}, (err, schemas) ->
schemas.forEach((schema) ->
))
load_schema: (schema, callback) ->
.verbose('SchemaManager> add:', schema.name)
Schema = .Schema
[schema.name] = new Schema(schema.definition)
.apply_plugins([schema.name])
callback([schema.name]) if callback
model: (schema_name) ->
return [schema_name] if [schema_name]
return null unless [schema_name]
[schema_name] = .model(schema_name, [schema_name])
module.exports = SchemaManager