SO, recently I am converting my React app pulse netlify lambada function app to the next-js app. But I came across the problem in the mongoose modal Error not Erro but problem. Here is my User Schema.
const mongoose =require('mongoose');
const { Schema } = mongoose;
const User = new Schema({
name:String,
password:String,
LikePage:[String],
url:String,
});
exports.User=User;
And this my adding Into data base function
const add = async (data, Modal) => {
// console.log('i am call');
console.log(data,Modal);
// let isOk=false;
const name = data.name;
// console.log(User)
return await Modal.findOne({ name }, async(err, value) => {
if (err) return console.log(err);
// console.log(value);
if (value === null) {
const document = await new Modal(data);
if(!document.name){
console.log(data,document)
console.log(document instanceof UserInfo)
return;
}
await document.save();
return true;
}
return false;
// return data;
});
}
All things are working fine. like connect to database, creating mongoose modal etc. And I am also not getting any waring and error. but we i insert data or make post request to api/adduser the emplty data insert in mongose.
like below photo
=====
And same code working fine in netlify lambda and react js app. Can anybody knows the reason. The whole code : hear
Aucun commentaire:
Enregistrer un commentaire