I am trying to find by id and getting bankApp.find is not a function.
This is my schema
import {model, Schema} from "mongoose";
const StatusResponse = new Schema({
uniqueKey: {type: String, trim: true, unique: true},
leadKey: {type: String, trim: true, unique: true},
riskStatus: {type: String},
}, {timestamps: true});
module.exports.statusModel = model('Status', StatusResponse);
This is my code where I am using .find()
const StatusResponse = require('../../models/StatusResponse');
exports.createApplication = async (req, reply) => {
const data = req.body;
let response = StatusResponse.statusModel(data);
await response.save();
let find = await response.find({"_id": "aaa"}).;
}
.save is running perfectly fine. But not able to figure out why .find() is not running.
Why response.find()
??
it should be a Model.find();
like below
let find = await statusModel.find({"_id": "aaa"}).;
use
StatusResponse.find({"id":"aaa"})
and you are saving your data in worng way, you can use
const response = new StatusResponse(data); await response.save();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.