Tuesday 23 May 2017

How do I export my mongoose model on NPM?

I want to export my mongoose model on NPM so that I could use it on another project.

Currently, I have two separate applications that will use the same mongoose model, and possibly both will run on two separate instances. One will be main application and another one will be the admin.

enter image description here

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const UserSchema = new Schema({
  name: String,
  photo: { type: String, default: "http://placehold.it/350x150"},
  created: { type: Date, default: Date.now },
});

module.exports = mongoose.model('User', UserSchema);

So technically how would I export this to NPM so that I could it on my admin folder



via sinusGob

No comments:

Post a Comment