2
I’m trying to access the Mongoose bank, doing a find on the nodejs. In Mongoose, I have the following data:
Client:{
name: {type: String, trim: true, required: false, default: ""},
address:{
country: {type: String, trim: true, required: false, default: ""},
cep : {type: String, trim: true, required: false, default: ""},
state: {type: String, trim: true, required: false, default: ""},
city: {type: String, trim: true, required: false, default: ""},
neighborhood: {type: String, trim: true, required: false, default: ""},
street: {type: String, trim: true, required: false, default: ""},
number: {type: Number, required: false, default: 0},
complement: {type: String, trim: true, required: false, default: ""}
},
}
And I do the following find no nodejs:
var cepClient = req.body.cep;
Client.findOne({address:{cep: req.body.cep}} , function(err, cepClient) {...)};
I want to check if the cep I’m looking for is already registered, if not the variable cepClient will return null.
But this way above I can’t access the cep variable inside address that is inside Client. How do I make a Find
of a variable within a Array
?