skip to Main Content

Node.js+MongoDB can't save hashed password

I am trying to save password in MongoDB but have error: Error: User validation failed: password: Path `password` is required. Model: const {Schema, model} = require('mongoose'); const UserSchema = new Schema({ email: {type: String, unique: true, required: true}, password: {type:…

VIEW QUESTION

Mongodb – Getting error node BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer value:Array

I am working on a node js project where I am getting the following error : CastError: Cast to ObjectId failed for value "[ [ '63e8e6e8b8a285d68b1fbd0c', '63e9951ded54221a516fc622' ] ]" (type Array) at path "labels" because of "BSONTypeError" at ObjectId.cast (/var/www/html/IssueTracker/node_modules/mongoose/lib/schema/objectid.js:248:11)…

VIEW QUESTION

Mongodb – How to handle mongoose errors globaly

As for now, I'm using mongoose middleware to handle Mongoose specific errors (validation, cast, ....). I'm using the following code in all of my schemas: schema.post('save', handleValidationError); schema.post('findOneAndUpdate', handleValidationError); schema.post(['findOne', 'deleteOne'], handleCastError); Is there anyway to make this global in…

VIEW QUESTION

Mongodb – why does Fawn throwing an error like 'The provided mongoose instance is invalid' to Mongoose library version ^6.9.1

I have written the same code as the document suggests. const mongoose = require("mongoose"); const Fawn = require("fawn"); mongoose .connect("mongodb://0.0.0.0:27017/rental") .then(() => console.log("Database rental connected")) .catch((err) => console.log(err.message)); Fawn.init(mongoose); And the error is: C:xampphtdocsmongo-rentalnode_modulesfawnlibfawn.js:30 throw new Error("The provided mongoose instance…

VIEW QUESTION
Back To Top
Search