Issue I am working on a application and I am using MEAN stack as technology. In AngularJS, I am using ngResource to CRUD operations. Can any one suggest how to send username and password to server and get response back
Continue readingTag: mongoose
NodeJS can't take my DB values for my template
Issue I started to develop a little web site in NodeJS, with admin authentication based on https://github.com/DanialK/Simple-Authentication, it work very well. I can create a user, login with it and see the private page (dashboard). But I have a problem
Continue readingMongo error, i can't run my two applications
Issue I generated two projects with the AngularJS Full-Stack Generator. The problem is when i run the command gulp serve in both projects, only opens one of them. In the console of the other project it show me: (node:1236) DeprecationWarning:
Continue readingMongoose – session abortTransaction is not rolling back
Issue I don’t know what I’m missing but in the block catch session.abortTransaction() not rolling bak anything. I purposely used throw new Error("Error message") after the creation of a user to land in the catch block to trigger the session.abortTransaction()
Continue readingQuery mongoose for every single element in array
Issue I want to query mongoose for every single element in an array (which itself is also result of a query to mongoose) and append the result to each array element respected and return the array: Service.find(query) .then((servicesList) => {
Continue readingI am getting an error "Error: User validation failed" in MongoDB
Issue I am getting an error after trying to use the POST method through postman to register a user. I have created a simple Schema for the register route. Error: Error in register: Error: User validation failed: password: Cast to
Continue readingDiscord Bot | Ranking (Leaderboard?) System with discord.js and MongoDB
Issue I have a few questions to ask about a ranking (leaderboard…?) system in discord.js using MongoDB. I am following a tutorial made by CodeLyon for the setup of MongoDB, but afterwards I went ahead and created my own XP
Continue readingMongoose Model Custom Error Message for Enums
Issue I would like to customize the validation messages that my Mongoose Models produce. I tend to NOT put my validations (e.g. required) on the schema object directly because there is no freedom to have custom error messages. e.g. sourceAccountId:
Continue readingHow to create interconnected schemas in MongoDB with Mongoose?
Issue I am creating an web app for users to store their daily expenses. The app is in NodeJS and using Express. The schema for collecting users and users’ data is as follows: const dataSchema = new mongoose.Schema({ email:String, date:String,
Continue readingMongoose: Find name similar to input
Issue I have an auto complete input box that I am working on and I am trying to make a mongoose endpoint that will get me user objects based on data from the input. The data can be incomplete, but
Continue readingMongoose getting newly saved object id off by one
Issue I’m using the latest version of mongoose. var question = new CodingQuestion(reqJSON); question.save(function(err) { if (err) console.log(err); else{ var questionId = question.id; console.log(“successfully added question with id”, questionId); } }); The new object can be saved successfully. The problem
Continue readingMongoose – Difference between Error.ValidationError, and Error.ValidatorError
Issue The question pretty much says it all. As far as I can tell from the docs, one is for general validation errors (a required field not being included, maxLength being exceeded, etc.). And one is given as the reason
Continue readingSeeding my database for FoodApp API using Faker cant use both import and require in the same file
Issue I am trying us use the Faker npm package to seed data into my new database so that I can properly test my filters. The issue is that I am unable to use both require and import in the
Continue readingMongoose where value in array
Issue I have the below code to return all blogs where the blog author ID is equal to the ID of the first administrator (orgAdmin) in an array: let officialBlogs = await Blog.find().where(‘author.id’).equals(help.orgAdmins[0]); But I can’t work out how to
Continue readingQuering documents into one specific property in MongoDB
Issue I wanted to query all "doc" properties inside the "doc", like a nested. I guess you can understand further what I want to explain from the code below: mongoose.connect("mongodb://127.0.0.1:27017/stationDB"); const docSchema = mongoose.Schema({ naturka: String, address: String, coefficient: String,
Continue readingusing ObjectId as a data type
Issue I’m trying to create a schema for an object and I’m using ObjectId as type but he gives me an error const mongoose = require("mongoose"); const permissionsSchema = new mongoose.Schema({ roleId: { type: ObjectId, required: true, }, menuPageId: {
Continue readingExpress and Mongoose: Cannot read property 'name' of undefined in Postman
Issue I am attempting to create and insert ‘user’ json documents, defined in the model below, upon a POST request to localhost:3000/api/student. I am greeted with the following error using postman to send POST requests: TypeError: Cannot read property ‘name’
Continue readingNest can't resolve dependencies of the UserModel (?)
Issue When I try to use MongooseModel on Users I am getting the following error Nest can’t resolve dependencies of the UserModel (?). Please make sure that the argument DatabaseConnection at index [0] is available in the MongooseModule context. /src/database/database.module.ts
Continue readingHow can I restrict the ability to post and save data to the database to only the admin in node.js?
Issue In the users table, I have two collections, one of which is admin and the other which is not. Now I only want admin user to post data. Here is the post request: router.post("/bus/add", auth, async (req, res) =>
Continue readingHow to create a class that's extended with a Mongoose Document type
Issue I have setup my application to use Mongoose to write to a MongoDB database and it works fine. Now, I am trying to add some tests and I am having trouble instantiating a mockup class to use in the
Continue readingRendering database documents inside the templete, EJS
Issue I cannot render the database documents inside the EJS. It throwing error like "TypeError: req.next is not a function". Piece of code that causing the issue is shown below: const stockSchema = mongoose.Schema({ rollingStockNumber: String, docs: { naturka: String,
Continue readingHow to add a "pre" middleware to mongoose model AFTER creating the model
Issue I need to add a pre mongoose middleware to a model (not schema) after the model was created from the schema. const mongoose = require(‘mongoose’); const FooSchema = new mongoose.Schema({ foo: String }); const FooModel = mongoose.model(‘Foo’, FooSchema); And
Continue readingMongoDB showing the schema as undefined
Issue While retrieving documents from database values are shown as undefined in console log. Piece of code that causing that issue. const stockSchema = mongoose.Schema({ rollingStockNumber: String, docs: { naturka: String, address: String, coefficient: String, wheel: String, weight: Number }
Continue readingIssue with querying dates with $gte and $lt
Issue I want to make searchDate API (I am using Express, Mongoose and Angular). I need to return list of data between two dates. Somehow it is working only if I hardcode date in $gte and $lt My api code:
Continue reading(MONGODB) How to remove referenced data when parent collection is deleted
Issue I have two schemas Folders and a model file as below. FolderSchema const mongoose = require(‘mongoose’) const {ObjectId} = mongoose.Schema const folderSchema = new mongoose.Schema({ title:{ type: String, }, belongsTo:{ type:ObjectId, ref:"Project" } }) module.exports = mongoose.model("Folder",folderSchema) modelFileSchema const
Continue readingWhy can't my AWS Lambda node JS app access my MongoDB Atlas cluster?
Issue Context : I have just created a Node.JS application and deployed it with the Serverless Framework on AWS Lambda. Problem : I would like that application to be able to access my (free tier) MongoDB Atlas Cluster. For this
Continue readingSumming the values in mongoose
Issue I have a mongoose Schema which keeps track of 5 types of accidents every year . Now I also want a "Total Accidents" column which should simply sum up the values of those 5 columns and gets updated every
Continue readingMongoose find field with any value
Issue I have a find query like: person = await PersonSchema.find({ givenName: (gn == ‘none’) ? {} : gn, lastName: (ln == ‘none’) ? {} : ln, placeOfBirth: (pob == ‘none’) ? {} : pob, dob: { $regex: (dob ==
Continue readingNestJS Mongoose Schema Inheritence
Issue I am attempting to inherit Mongoose Schemas or SchemaDefitions within NestJS but I am not having much luck. I am doing this so I can share Base and Common Schema Definition Details such as a virtual(‘id’) and a nonce,
Continue readingGet a flat array of deeply nested items in MongoDB
Issue I am building a side project that uses a mongodb database. I am using the MERN stack to build out a web application with my data. I am using Mongoose to get data from my database on a NodeJS/Express
Continue readingHow can I update multiple documents in mongoose?
Issue I found the following script: Device.find(function(err, devices) { devices.forEach(function(device) { device.cid = ”; device.save(); }); }); MongoDB has the "multi" flag for an update over multiple documents but I wasn’t able to get this working with mongoose. Is this
Continue readingMultiple MongoJS calls in Node.js
Issue I am working on a node.js which has multiple steps with Mongo: Get a document Push a subdocument into the subarray and save Do an aggregation framework query to get the inserted subdocument Return it to the calling function
Continue readingHow to update a specific nested array inside a MongoDB document
Issue So I have a primary mongoDB object that has multiple documents nested within. I want to access a specific document in an array and modify one of its values. This is my document setup const sectionSchema = new mongoose.Schema({
Continue readingMongoose find problem – TypeError: Cannot read property 'find' of undefined
Issue I’m having a issue with a mongoose find() query, which I cannot figure out. the error I receive is "TypeError: Cannot read property ‘find’ of undefined" which I suspect is an export/import problem. Any help would be greatly appreciated.
Continue readingType is missing the following properties from type 'Schema<any, Model<any,any,any,any>, {}, {}>': add, childSchemas, clearIndexes, clone, and 37 more
Issue I’ve got a Mongoose on TypeScript, and it worked without interfaces and types defining, but when I decided to define types, the madness started. I’ve watched tons of manuals and topics and found nobody with a similar problem. I
Continue readingHow can I $push an item in two different fields, depending on the condition?
Issue I’m trying to receive the user location and store it in the database. Also, the user can choose if he wants to save all his previous locations or not. So I have created a boolean variable historicEnable: true/false. So
Continue readingPrevent mongoose from inserting template Schema in db
Issue I am creating a demo gaming web app with express and mongoose. There are several game types such as quizzes and puzzles. I am trying to create one main Schema Games, which gets inherited from other Schema game types.
Continue readingcan not get userID in sequelize?
Issue this is user model const { Model } = require("sequelize"); module.exports = (sequelize, DataTypes) => { class User extends Model { /** * Helper method for defining associations. * This method is not a part of Sequelize lifecycle. *
Continue readingShow only records where an array of objects exists for logged in user
Issue Users can add multiple products and multiple users can request that product. When a user logs in, I want to show only products that have requests. I tried this which is supposed to firstly find products for the userId
Continue readinghow to check if mongoose (MongoDb) is installed or not
Issue I installed mongoose using sudo npm install -g mongoose Please advice on how I can check to see if its installed properly. I am using Mac Solution To check if mongoose module is installed simply find the version by
Continue readingIs there a way to get only User item from a collection using Mongoose DB?
Issue So this is my Schema folder: module.exports = mongoose.model( ‘premium’, new mongoose.Schema({ User: String, Name: String, Expire: Number, Permanent: Boolean, }) ); So I want to get from database only User and Name items and use it in embed
Continue readingHow to add index weight on two id fields on MongoDB?
Issue I have a question regarding Mongo indexes for a $or request on two ObjectID fields. How can I make sure a search will first look at the first argument of the $or expression and only then if no match
Continue readingThe 'model' property does not exist in the 'IUserDocument' type
Issue I’m trying to create my own interface and extend the Document from Mongoose, so I did: users.types.ts import { Document, Model } from ‘mongoose’ export interface IUser { chatId: Number, username: String, name?: String, firstName?: String, lastName?: String, age?:
Continue readingMy save data to MongoDB not functioning, is it because my searching is wrong?
Issue I’m trying to make a comparison function. If the value that I search is not exist, the new value will be save to the database. But all I get is 0 new data found. So the system decides to
Continue readingHow to filter the response from mongoDB, so nested arrays will include only items that meet a condition?
Issue My documents look like this { "_id": { "$oid": "62825f71005ce00c5f0235c1" }, "user": "jon", "roles": { "User": 2001, }, "STOCK ": [ { "sku": "BLACK-M", "productname": "BLACK", "sendout": 0, "recived": 1, "totalinstock": 40, "location": "B32", "_id": { "$oid": "62826016005ce00c5f0235c8" }
Continue readingHow can I add custom keys to to mongoose schema item?
Issue I have a simple mongoose schema for a post: const postSchema = new mongoose.Schema({ title: { type: String, required: true, unique: true }, body: { type: String, required: true, unique: false } }) And I would like to add
Continue readingWhy spread operator is showing only the last entered data in a for loop?
Issue In a GET request I am using a spread operator in a for loop but it is showing only the last entered data only(data about seats) from the database. The GET request: router.get("/trip/single", async (req, res) => { if
Continue readingI can't replace the value of an array returned by mongoose
Issue I have a notifications.find query (mongoose) that returns multiple sheets Notification.find({id: id}, function(err, notifications){} I need to convert the timestamp values that are returned like that [ { _id: new ObjectId("12934193c51a231b0165425a"), userid: ‘62921df1c14a2eea0efa9399’, timestamp: 1653817696599, }, { _id: new
Continue readingWhy mongoose.model() is required to get data from MongoDB?
Issue I want to read data from the mongodb with mongoose, but every time it requires creating a model. Why? I thought model are just like templates to insert data to MongoDB. Can anyone describe what exactly mongoose.model() is and
Continue readingHow to populate data from another collections in mongoose?
Issue I want to populate the busNumber from bus Bus table to the trip table. Here’s the bus model const busSchema = new mongoose.Schema( { busNumber: { type: String, unique: true, required: true, }, seats: { type: Number, }, },
Continue readingHow to populate the nested objects in mongoose?
Issue here’s the booking schema const bookingSchema = new mongoose.Schema({ userId: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true, }, routeId:{ type: mongoose.Schema.Types.ObjectId, ref: "Route", required: true, } }) In this table the routeId(route schema) contains the Bus table(referenced). const routeSchema
Continue readingMongodb Populate is not populating document in Node.js
Issue I am using typegoose and my Query and QueryRule models are as below. export class Query { @prop() queryRule: Ref<QueryRule>; } export class QueryRule { @prop() condition: Condition; @prop() rules: Ref<QueryRule | ChildRule>[]; } I am using the following
Continue readingReferencing a schema, not a model
Issue I want to reference to a subdocument which is defined as a schema. Here’s the example: exam.model.js: const answerSchema = new mongoose.Schema({ text: String, isCorrect: Boolean, }); const questionSchema = new mongoose.Schema({ text: String, answers: [answerSchema], }); const examSchema
Continue readingHow can I get data other than 24 Hours in Mongoose
Issue var allData = await Account.find({}) var hoursData = await Account.find({"_time":{ $gt:new Date(Date.now() – 24*60*60 * 1000) }}) var AllData_array = []; allData.forEach(data => { var _WalletAdress = data._WalletAdress; AllData_array.push(_WalletAdress) }); var HoursData_array = []; hoursData.forEach(data => { var _WalletAdress
Continue readingcan someone tell me what this error mean?
Issue MongoError: cannot do raw queries on admin in atlas i tried to run : mongoose .connect( ‘mongodb+srv://yonco:mypassword@shop.iujhp.mongodb.net/?retryWrites=true&w=majority’ ) .then(result => { User.findOne().then(user => { if (!user) { const user = new User({ name: ‘yonc’, email: ‘yonc@rest.com’, cart: { items:
Continue readingFetch/Find child collection using mongoose
Issue I am newbie in MongoDB. I am having some problem for nested collection. Suppose I have 3 different collections in mongodb. (1) classes (2) subjects and (3) chapter. Classes contain various class name, subjects contain different subject name for
Continue readingNode JS + Mongo DB: ValidationError: User validation failed: username: Path `username` is required
Issue When I am trying to Save/Create a New Document (User) to Mongo DB using Mongoose, I am getting the following Validation Error in spite of providing all the Values with proper DataType: ValidationError: User validation failed: username: Path username
Continue readingHow to exclude array of ids from query
Issue I have an array of _ids and I want to exclude them from the query: console.log(‘relatedCards’, relatedCards); const motherCards = await db.MotherCard.find({ "_id": { $ne : relatedCards } }); But it returns this error: Why this is happening and
Continue readingHow to run raw mongoDB commands using mongoose?
Issue I’m able to change the mongodb’s-sort-buffer-size using below command db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes: <limit in bytes>}) but, how to run the same command using mongoose library? Solution Try this: YourModel.db.db.admin().command({setParameter: 1, internalQueryExecMaxBlockingSortBytes: <limit in bytes>}, function (err,res) { console.log(res); });
Continue readingThe options [useMongoClient] is not supported
Issue I am using mongodb-3.6.0. My express code is var promise = mongoose.connect(‘mongodb://localhost/myapp’, { useMongoClient: true }); On running the app I am getting the options [useMongoClient] is not supported. My mongoose version in ^5.0.0-rc0. Please help. Solution There is
Continue readingUpdate multiple documents and return all updated documents
Issue I am looking for a way to update many documents at once using mongoose and return all the modified documents. I tried with setting multi:true in update(). It is updating all matching documents but not returning any. Then I
Continue readingCreating documents that contain subdocuments with Mongoose
Issue I am trying to create my MongoDB Atlas database but the subdocument values are not coming through. Am i supposed to loop through them somehow ? Can’t find any solutions. Thanks Postman request: { "name" : "New Avengers", "items":
Continue readingIn nodejs, how do I traverse between embedded mongodb documents to get the values of their keys
Issue So, I have a different mongodb documents in relationship with one another. I want to be able to get access to the the different keys and their values starting with the parent document all the way down to the
Continue readingMongoose FInd and remove object from array of a document
Issue I have a document ‘Collection’: { name: {type: String, required: true, default: “Untitled Collection”}, movies: [ { the_id: {type: String}, movie_id: {type: String}, tmdb_id: {type: String}, original_title: {type: String}, release_date: {type:Date} }], author: {type: String},} I need to find
Continue readingThe pre hook is not working with find queries
Issue /*The pre hook is supposed to populate the teacher field, but for some reason it didn’t.Somehow when populate directly from the controller it works!*/ exports.getAssignment = catchAsync(async (req, res) => { const assignment = await Assignment.findById(req.params.id).populate( ‘teacher’ ); if
Continue readingMongoose how to count unique days in a month?
Issue i am working on a problem where in my database there supposed to be multiple entries from day to day. each entry includes a timestamp. the problem is im supposed to find how many days in each month a
Continue readingMongooseError: Operation `users.findOne()` buffering timed out after 10000ms
Issue This is my connection file const connectDB = async () =>{ const conn = await new mongoose("mongodb+srv://nikunj:gadia7420@cluster0.94xph.mongodb.net/myFirstDatabase?retryWrites=true&w=majority", { usenewurlparser:true, usecreateindex:true, usefindmodify:true, useunifiedtropology:true, urlencoded:true }) } module.exports = connectDB; this is my models file const userSchema = new mongoose.Schema({ username:{
Continue readingHow to access a preexisting collection with Mongoose?
Issue I have a large collection of 300 question objects in a database test. I can interact with this collection easily through MongoDB’s interactive shell; however, when I try to get the collection through Mongoose in an express.js application I
Continue readingMongoose populate() returns the '_id' field of populated documents with "new ObjectId()"
Issue So I’m trying to fetch a set of company member documents that correspond to a specific user, and populate the company field of each document in the process. The aim here is to get the _id and the name
Continue readingExpress async get request, calling async function hanging
Issue Hello I’m new to express… I have an express file like: const app = express(); const getPerson = require("./db/queries/PersonQuery"); app.get(‘/getCitizen/:id’, async (req, res) => { try { const person = await getPerson.getCitizenById(`${req.params.id}`); console.log(person); res.send(person); } catch (e) { console.log(e);
Continue readingStore wrong timezone in default date and time
Issue I am trying to store default date and time using mongoose with the Node.JS but somehow, it is storing different time zone value in database. I’m using "MongoDB Atlas Database" as a DB server and also configured default time
Continue readingRemove _Id from mongoose Aggregate response
Issue I’m trying to remove the _Id from the returned documents, this is my code: module.exports = function(app) { // Module dependencies. var mongoose = require(‘mongoose’), Contacts = mongoose.models.Contacts, api = {}, limit = 10; api.contacts = function(req, res) {
Continue readingNodejs exports returns undefined on mongoose Insertion
Issue I have created nodejs application by organising as module structure , The problem I am facing is that a mongodb insertion return undefined value from one of my controller, The issue I found is that my async funtion doesn’t
Continue readingcannot read property '_id' of undefined when user signed out
Issue I am trying to set conditional logic using user id so that if the authenticated user is the same user who created this post, don’t show the like button. This works however if the user is not signed in,
Continue readingHow to create public shareable link for private user resources in MERN application
Issue I am creating a movie web application using MERN stack where a user can sign up and login. Users can also add the movies they like to their respective list. Now, I want to add a feature where the
Continue readingTypeError: Cannot create property '_fullPath' on string ''
Issue This mongoose error was shown when populating collections. Model.find().populate(‘someCollection’) Solution This error was generated with the version 6.1.3 of mongoose . To prevent this horrible fault from mongoose team please downgrade it to 6.1.2 Answered By – chiheb bel
Continue readingNode.js Express case-insensitive search (filter) through MongoDB database
Issue I want to make case-insensitive search API (I am using Express, Mongoose and Angular). I have datatable in my Angular application and Input field. So my API should return me data by (onChange). I have two collections (containers and
Continue readingHow To Search An Object Property in An Array of Objects? Mongoose, MongoDB
Issue Edit: I have solved my problem. The solution is in the comments. I’m trying to allow users to link other accounts to their main accounts on my app. When they go to link an account I want to ensure
Continue readingMongoDB – How to get content from a specific field only
Issue What is the best way to retrieve the content from specific fields only in Mongo? Using Mongoose, here is my Schema: module.exports = mongoose => { const Shop = mongoose.model( ‘Shop’, mongoose.Schema( { cid: String, title: String, categoryName: String,
Continue readingWhy is my function returning Promise { <pending> }
Issue As my first real MERN project, I’m building a message board. I’m currently working on a node route to request the board names with their associated post count but I’ve hit an issue. Instead of getting the values that
Continue readingOptimize mongoDB query to get count of items from separate collection
Issue I have two collections namely "tags" and "bookmarks". Tags documents: { "taggedBookmarksCount": 2, "taggedNotesCount": 0, "_id": "627a80e6b12b0dc78b3a6d4b", "name": "Article" }, { "taggedBookmarksCount": 0, "taggedNotesCount": 0, "_id": "62797885b479b5906ef6ed43", "name": "Client" }, Bookmark Documents: { "_id": "627a814db12b0dc78b3a6d54", "bookmarkTags": [ { "tagId":
Continue readingReact – using express router, mongoose, which approach is better?
Issue Giving by example the GET route request below, both WORK. I am trying to understand their differences and which one is the best approach for doing this. Any comments on the 2 coding options, please? Option 1 router.get("/", (req,
Continue readingWhy should we use mongoose ODM instead of using directly Mongodb with mongodb driver for Nodejs/Express?
Issue I have just started up with mongodb and I recently gone through Mongoose, an ODM for MongoDb. On the documentation, I couldn’t find why we need to use Mongoose instead of using Mongodb directly except one reason which is
Continue readingHow to search for records by using a value in object array from mongoose?
Issue I want to search for records using the below-mentioned Field and code I have used, returning nothing. I’m sure I’m querying wrongly, and can anyone help me build the correct query code? Code I have used: const { id
Continue readingSaving array of children of a Mongoose Schema and then adding returned IDs to parent
Issue i’m trying to loop over an array of objects, saving them to MongoDB and then add the returned ObjectIds to a parent Schema which then is also saved. I’m at a loss here. Everything gets saved correctly but the
Continue readingMongoose datetime and timezone, how to get datetime based on server timezone
Issue The first answer of this question suggests that mongoose would adapt the date according to server timezone when retrieving data. However, I don’t have this comportement. I set the (node) server timezone with : process.env.TZ=’Europe/Paris’ For exemple if I
Continue readingHow to create sub document in mongoose? MongoDB, NodeJS
Issue I am trying to implement an array of comments as a subdocument, in my main document of posts, I am new to js and mongoose, while I tried updateOne, it is working, but it is not working if I
Continue readingHow to define object in array in Mongoose schema correctly with 2d geo index
Issue I’m currently having problems in creating a schema for the document below. The response from the server always returns the “trk” field values as [Object]. Somehow I have no idea how this should work, as I tried at least
Continue readingHow can I save multiple documents concurrently in Mongoose/Node.js?
Issue At the moment I use save to add a single document. Suppose I have an array of documents that I wish to store as single objects. Is there a way of adding them all with a single function call
Continue readingHow to remove a specific key from JSON response coming from MongoDB in ExpressJS
Issue I’m creating a simple application using MEAN stack. My code is working fine but i want to remove one key from the response. Please look at my ocde. models/user.js const mongoose = require(‘mongoose’); const Schema = mongoose.Schema; const userSchema
Continue readingNodeJs: how to assign additional objects to mongoose query response JSON
Issue Using mongoose I am querying a list of posts and would like to determine whether or not the user has liked the image or not within the query function by adding a boolean to the response JSON. I am
Continue readingModify object in Mongoose pre-save hook
Issue In a GeoJSON Polygon (or more strictly: LinearRing), the last set of coordinates needs to evaluate to the same value as the first one: [[0,0], [0,1], [1,1], [1,0]] // bad [[0,0], [0,1], [1,1], [1,0], [0,0]] // good I would
Continue readingMongoose use of .select() method
Issue I’m pretty confused with the use of the select method. This is how I use it, and it’s wrong: Transaction.find({username : user.username}).select(‘uniqueId’, ‘confirmation_link’, ‘item_name’, ‘timeout’, ‘username’, function(err, txs){ callback(txs); }); What I’m trying to achieve is simply to select
Continue readingHow to say custom message that the Email is unique from mongoose Schema
Issue How to say the custom message that the Email is unique from mongoose Schema. I do not want to check that this email exists or not from my back-end because I already said in mongoose schema that email: {
Continue readingbcrypt password is changing after a time
Issue I have created a app similar to blog app. Users can registered and login logout. When User creates it’s account than logout than s/he can login again with the same password. However, after a spesific time(I couldn’t specify the
Continue readingIs there a less verbose way to write DynamoDB update params?
Issue I am new to Dynamo and I created a simple todo API with Serverless Framework and TypeScript To update an Item I have to do this huge params const const params = { TableName: process.env.DYNAMO_TABLE_TODO, Key: { id: event.pathParameters.id,
Continue readingNodeJS and MongoDB – use aggregate and $lookup together with findById
Issue I want to make a relation between two collections – a book and author collections. If i use only get and display all of my books and integrate the data about author by id it works. Author schema: const
Continue readingNodejs Get fetch values excluding matching field array value from Mongo
Issue How to make a find in Nodejs to get the values excluding the Given ID. {"_id": {"$oid": "1"}, "image_name": "img1.jpg", "price": 120, "user": [{ "$oid": "userid1" }], "category": [{ "$oid": "cat1" }] "__v": 1 } {"_id": {"$oid": "2"}, "image_name":
Continue readingTypeError: Room.findOne is not a function
Issue I just learning how to build a database by using Im trying to add data to mongoDB and using the .findOne function, but I’m getting this error. is findOne a function in MongoDB? My Goal is I trying to
Continue readingFind one or create with Mongoose
Issue I have Page.findById(pageId).then(page => { const pageId = page.id; .. }); My problem is that if no page id is given, it should just take the first available page given some conditions, which is done by Page.findOne({}).then(page => {
Continue reading