How to use the @lykmapipo/mongoose-common.model function in @lykmapipo/mongoose-common

To help you get started, we’ve selected a few @lykmapipo/mongoose-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lykmapipo / mongoose-gridfs / lib / bucket.js View on Github external
// construct file schema
  const schema = createFileSchema(bucket);

  // apply schema plugins with model options
  const schemaOptions = _.merge({}, schema.options);
  _.forEach([...plugins], plugin => {
    schema.plugin(plugin, schemaOptions);
  });

  // hack(to be removed): fake timestamp fields
  schema.statics.CREATED_AT_FIELD = 'uploadDate';
  schema.statics.UPDATED_AT_FIELD = 'uploadDate';

  // compile file model
  const fileModel = model(modelName, schema, connection);

  // return model
  return fileModel;
}