lib/model/api.js
function createFromMetadata (connector, modelsMetadata) {
    if (!connector || !modelsMetadata) {
      throw new Error('Please provide both connector and metadata so Arrow could create models')
    }

    const loadModels = connector.config.generateModels

    return Object.keys(modelsMetadata).reduce(function (previousModels, modelName) {
      const persistModels = connector.config.persistModels
      if (loadModels && loadModels.indexOf(modelName) === -1) {
        return previousModels
      }
      const metadata = modelsMetadata[modelName]
      metadata.autogen = !!connector.config.modelAutogen
      metadata.generated = true
      metadata.connector = connector.name
      metadata.name = modelName

      dataValidator.validate(metadata, metadataSchema)

      if (persistModels) {
        utils.saveModelSync(createModelName(connector, modelName), metadata, connector.modelDir)
      } else {
        previousModels[modelName] = Arrow.createModel(createModelName(connector, modelName), metadata)
      }
      return previousModels
    }, {})
  }
function createFromMetadata (connector, modelsMetadata) {
    if (!connector || !modelsMetadata) {
      throw new Error('Please provide both connector and metadata so Arrow could create models')
    }

    const loadModels = connector.config.generateModels

    return Object.keys(modelsMetadata).reduce(function (previousModels, modelName) {
      const persistModels = connector.config.persistModels
      if (loadModels && loadModels.indexOf(modelName) === -1) {
        return previousModels
      }
      const metadata = modelsMetadata[modelName]
      metadata.autogen = !!connector.config.modelAutogen
      metadata.generated = true
      metadata.connector = connector.name
      metadata.name = modelName

      dataValidator.validate(metadata, metadataSchema)

      if (persistModels) {
        utils.saveModelSync(createModelName(connector, modelName), metadata, connector.modelDir)
      } else {
        previousModels[modelName] = Arrow.createModel(createModelName(connector, modelName), metadata)
      }
      return previousModels
    }, {})
  }
function createFromMetadata ( connector , modelsMetadata ) { if ( ! connector || ! modelsMetadata ) { throw new Error ( 'Please provide both connector and metadata so Arrow could create models' ) } const loadModels = connector . config . generateModels return Object . keys ( modelsMetadata ) . reduce ( function ( previousModels , modelName ) { const persistModels = connector . config . persistModels if ( loadModels && loadModels . indexOf ( modelName ) === - 1 ) { return previousModels } const metadata = modelsMetadata [ modelName ] metadata . autogen = ! ! connector . config . modelAutogen metadata . generated = true metadata . connector = connector . name metadata . name = modelName dataValidator . validate ( metadata , metadataSchema ) if ( persistModels ) { utils . saveModelSync ( createModelName ( connector , modelName ) , metadata , connector . modelDir ) } else { previousModels [ modelName ] = Arrow . createModel ( createModelName ( connector , modelName ) , metadata ) } return previousModels } , { } ) }
Create models in memory on persist them on disk depending on the configured strategy.

@param {object} connector
@param {object} modelsMetadata
@return object that holds all the models or empty object in case we use persistence strategy
Create models in memory on persist them on disk depending on the configured strategy .