skip to Main Content

Mongodb – MongooseError: Model.findOne() no longer accepts a callback at Function

I've encountered a problem while setting up mongoose. Here is my code: const { SlashCommandBuilder } = require('@discordjs/builders'); const testSchema = require(`../../Schemas.js/test`); module.exports = { data: new SlashCommandBuilder() .setName('dbtest') .setDescription('db test'), async execute(interaction) { testSchema.findOne({ GuildID: interaction.guild.id, UserID: interaction.user.id}, async(err,…

VIEW QUESTION

mongoose error: model.find() no longer accept call back – Jquery

Here is my full app.js code. //jshint esversion:6 const express = require("express"); const bodyParser = require("body-parser"); const mongoose = require("mongoose"); const _ = require("lodash"); const app = express(); app.set('view engine', 'ejs'); app.use(bodyParser.urlencoded({extended: true})); app.use(express.static("public")); mongoose.connect("mongodb://localhost:27017/todolistDB", {useNewUrlParser: true}); const itemsSchema =…

VIEW QUESTION

Mongodb – mongoose code showing error of a call ack function

app.post ('/create_contact',function(req,res) { contact.create({ name :req.body.name, phone:req.body.phone },function(err,newContact) { if(err){console.log('error in creating a contact!'); return;} console.log('********',newContact); return res.redirect('back'); }); }); Errors: throw new MongooseError('Model.create() no longer accepts a callback'); ^ MongooseError: Model.create() no longer accepts a callback I tried this…

VIEW QUESTION

Mongodb – FindOne and sort in array with Mongoose

How can i get sorted data in array by "name" in categories where '_id = 63fe948a22009cbbba53b905'? My sample data: { "_id": "63fe948a22009cbbba53b905", "options": { "sort": "manual" }, "categories": [ { "priority": 0, "options": "manual", "name": "Nazwa 1", "_id": "63fe8cc76d50062ae1f53821" },…

VIEW QUESTION
Back To Top
Search