I’m new to mongoDB, I am trying to achieve the following SQL query on it. but could not find anything useful so far. can anyone tell equivalent mongoose query what I got so far is following UPDATE I have following name and export scheme Answer You can use filter out objects included in resulting array using match but in the
Tag: mongodb
MongoDB: $function operator does not support arrow function
I have following documents in testCollection: I am using regular expression to filter documents using $function operator. I get the correct output while using Query 1. Query 1: Output for Query 1: but for Query 2 I am getting all the documents and the filter is not working. In Query 2 I changed the function body to arrow function. Query
How to make sure that objects do not have the same two element in mongoose schema?
I am making the following mongoose schema and i want to make sure that no object has the same autherFirstName and autherLastName. object may have one in common but not both of them Answer https://mongoosejs.com/docs/2.7.x/docs/indexes.html Create a composite unique index
Is it necessary to use multiple Joi schema validations with Hapi?
I looked at an existing codebase and and I noticed that the codebase had two schema validations for what I feel a single schema could validate as the second schema is an offshoot of the first. See codebase below. Now these schema are being used in the following routes: I am new to Hapi but have some experience with Express
Not able to get the res.json() value from nodejs server
I am using react.js as frontend and nodejs for the backend. My client-side code is And My server-side code is Front-end output In the server-side code, you can see that I am returning the res.json. but On the client-side, I am not getting the value that I have returned from the server. Please, can anyone help me? Answer You need
mongodb project map fields to return from query with wildcard
I’m working on a system where I use a schema with the type Map much like this: I’m trying to query certain parts of the docs in this collection with a projection: I would like to only get the fields in data starting with xy. Do you have any hint how to do that? Answer Since Mongoose’s map type will
Please help, I have a problem, My conditional didnt work with data I gained from mongoDB.find()
I have a problem, I code using javascript and I use mongodb or mongoose as the database. I have a little information about async / await I made a variable called “thread” to get data from mongoDB using const thread = await Threads.findOne({threadId}) the thread will have data: { “_id”: “6044d0d8940c3b2494ce135d”, “threadId”:”A001} After that I want to use the _id
How do I query the database using Mongodb after I set up a Mongoose schema for authentication?
I successfully set up authentication for my app, which is a node.js (Express) app. I used Passport-local and I also used a Mongoose schema. The folder structure is like this: Inside the “models” folder is the User.js file, and it contains this schema: And the app.js (the main file) includes the following code. I am not showing everything by the
How can I return the results of my backend Query onto my frontend to display on a page
simple query I am currently trying to learn about the MERN stack and developing an application. This is my simple query where I am just searching for snacks with “orit” substring and thus return snacks with “Doritos” etc. How may I integrate this query or take the result and display it on a page on my frontend. Or perhaps there’s
Mongoose query where X is in both arrays and where Y is in only one array
I am building a filtering system and I am stuck on a problem, please keep in mind that this is demo code, this is not the same project but the concept is the same, I replaced the names to make it as easily understandable as possible. I got a filled filter object which gets sent like this (it consists of