var Schema = mongoose.Schema;
var roleSchema = new Schema({
name: {type:String, required:true,unique:required}
description: {type:String}
});
var model = mongoose.model(role, roleSchema);
{“name”:”Admin”,” description”:”Admin role”},
{“name”:”Employee”,” description”:”Employee role”}];
roleData.forEach(function(data){
model.insert(data, function (err, resul) {
console.log(resul._Id);
});
});
var Schema = mongoose.Schema;
var roleSchema = new Schema({
name: {type:String, required:true },
tenant : {type:String, required:true },
description: {type:String}
});
roleSchema.index({name: 1, tenant: 1}, { unique: true });
var model = mongoose.model(role, roleSchema);
{“name”:”Employee”,” description”:”Employee role”,”tenant”:”tenant1”},
{“name”:”Admin”,” description”:”Admin role”,”tenant”:”tenant2”},
{“name”:”Employee”,” description”:”Employee role”,”tenant”:”tenant2”}];
roleData.forEach(function(data){
model.insert(data, function (err, resul) {
console.log(resul._Id);
});
});