Changes have no effect when I change Schema, using mongodb and nodejs

Asked

Viewed 44 times

1

Every time I make a change in my Schema I have to restart my server.

I’m using the nodemon, but it doesn’t always update, someone has been through it?

module.exports = function(app){
    var Schema = require('mongoose').Schema;

    var localizacao = new Schema({
        name : { type : String, trim : true },
        loc : {
            type : String,
            cordinates : [ String ]
        }
    });

    var funcionamento = new Schema({
        abertura : { type : String, default : '00:00:00' },
        fechamento : { type : String, default : '24:00:00' }
    });

    var agentes = new Schema({
        nome : { type : String, trim : true, require : true, index : { unique : true } },
        senha : { type : String, trim : true, require : true },
        foto : { type : String, trim : true },
        telefone : { type : String, trim : true, max : 20 },
        localizacao : localizacao,
        simulador : { type : Boolean, default : true },     
        funcionamento : funcionamento,
        limites : [],
        nivel : { type : Number, default : 3 },
        visivel : { type : Boolean, default : true }
    }, 
        { timestamps: { createdAt : 'created_at', updatedAt : 'updated_at' } }
    );

    return global.conexao.model('agentes', agentes);
}
  • 1

    How are you changing your Schema? The way your question is is very open. Can [Edit] your question include more details like some example, snippet of code, how you created your Schema, etc?

  • ready I edited, Unique is not responding I am able to add duplicated Dice

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.