Questions tagged [mongoose]

Mongoose is a MongoDB object modeling tool, written in JavaScript, designed to work in an asynchronous environment.

20 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
247 views

Mongoose and Hapi/Express promise handling in controllers

I'm switching my code to promises - mostly as delivered by Mongoose. I use Hapi though I think something similar would apply to Express. In my models/services I perform queries such as: ...
3
votes
0answers
36 views

MongoDB BulkWrite - create or update a sub document within an array

I have a series of Events (roughly 10-20 events that will be dynamically created per month): Event Model: ...
3
votes
0answers
830 views

Mongoose schema for products and social media posts

Here is my current schema: Brand: ...
3
votes
0answers
180 views

Beginner's To-do app with Node.js

I get the feeling the code for this to-do app is not secure. I am just a beginner, and I don't know much about coding style so do you think it is conventional/elegant? Please don't hesitate to ...
2
votes
0answers
45 views

Clean code: Permission with middleware

In my example, I have four models: User, Company, Project, and Plant (though my project technically has more: Plant, Job, Team, etc.). ...
2
votes
0answers
34 views

Javascript RPC Call Handles Data and Returns DB Response

I have a service within a larger set of microservices that's handling a RPC call. My function mainly just parses through the request, uses the data to insert data into our MongoDB database, and then ...
2
votes
0answers
168 views

Rewrite two mongo queries to aggregation

Here is a code block I have: ...
2
votes
0answers
34 views

Storing products in MongoDB with support for sorting by their number of followers

I'm loading products via an infinite scroll in chunks of 12 at a time. At times, I may want to sort these by how many followers they have. Below is how I'm tracking how many followers each product ...
2
votes
0answers
123 views

CRUDL actions on MongoDB collection using Mongoose and NodeJS

I am using Mongoose ODM and NodeJS to implement CRUDL operations on MongoDB for further use with REST API. Initially, I've implemented functions using Promises but then switched back to callback style....
2
votes
0answers
72 views

Trade off in database efficiency versus a nested for loop on client

I built an app where a user has a recipe box with recipes in it - for the db, there is a user and recipe model, user has "recipeBox" property. The recipebox is an array of objects like so: User ...
1
vote
0answers
22 views

Writing error handling and users routing for my JSON RESTful API

I'm currently making an app for my side project and I was looking to get some insight on the main js file, what can I improve, the error handling, what am I doing wrong, etc. I'm mostly confused about ...
1
vote
0answers
69 views

Async API Function with Mongoose

I'm quite new to the language and I just started using async/await. I've written this function for an API that I'm developing. It checks what is sent by the user, specially the status that he wants to ...
1
vote
0answers
674 views

post Like/Dislike with mongoose/mongodb

Right now my route is doing the following: Searching for the post by id from the request parameters Check if the user already likes the post If the user likes the post, then increase ...
1
vote
0answers
225 views

Exporting functions that manipulate mongoose models

I have the following code in a file called database.js which will handle all the database operations for my small application. For some background, this application ...
1
vote
0answers
139 views

Implementation of user permissions

I am building a web-application in NodeJS (using TypeScript) and MongoDB (using Mongoose). In my application I have 6 types of permissions. For the simplicity, let's use ...
1
vote
0answers
25 views

Matching a current user's “liked / followed” items with results from a search query

This is pretty ugly now. My main objective is to perform a search query, which I do via mongoosastic / elastic search (the search paginates 12 items at time). Then, I want to match those results with ...
1
vote
0answers
31 views

Getting data from service and storing it in MongoDB

I wrote code to get data from HTTP service and store it in MongoDB. Please, can someone let me know how efficient my code is and whether it is good from the OOP point of view? ...
1
vote
0answers
3k views

A plugin that integrates Angular Smart Tables with Mongoose DB for server side pagination

I'm using Angular Smart Tables with data that might become a huge set of documents and rows. So rather than client side processing of the data for pagination, I borrowing code from two Mongoose.js ...
1
vote
0answers
33 views

Nesting models within models

I am saving data into a MongoDB. The data will be saved into 3 Mongoose models that are hierarchical. A User model contains an ...
1
vote
0answers
50 views

NodeJS socket for handling errors

It's the first time managing Mongoose by socket.io and I'm wondering if this could be a good way: ...