All Questions
65 questions
0
votes
0
answers
52
views
React based Quiz Website
I have recently worked on a quiz application using the MERN stack. The application incorporates various features such as user authentication, quiz creation, scoring functionalities, and data ...
1
vote
1
answer
86
views
Optimising a simple graphql mutation resolver
I am writing a resolver for a typical updateUser mutation with node, Apollo Server and mongoDB. I want to make it such that, when the ...
2
votes
1
answer
110
views
Basic node login routes for authentication system
I am building a basic authentication system with a node backend and wonder whether I am using the try-catch block excessively. I have this example controller:
...
2
votes
2
answers
73
views
Blog API implementation in node.js
This code is from my blog project. This project is almost done. This is working well.
I can create new posts and update and display all saved posts.
...
0
votes
1
answer
654
views
Import XML files to MongoDb with Nodejs
Here is my code which will read XML files and import the data to MongoDb. Do you have any comments on my code?
...
2
votes
1
answer
389
views
MongoDB Filter between two dates
Simple code for getting documents that have a creationDate between two values in mongodb.
If the user provides only one of the values the code should still work and ...
1
vote
1
answer
154
views
Basic REST API for manipularing a MongoDB collection, using Node, Express, and Mongoose
I'm practicing back-end programming and NodeJS. As an exercise, I'm attempting to build a REST API for a MongoDB collection. I'm also learning to use the Express and Mongoose middle-wares, so that's ...
2
votes
1
answer
122
views
Is this nodejs web-application spaghetti code?
I recently interviewed for a backend developer role at a startup involved in financial products, as a 2020 grad. The take-home assignment they had me submit had a few basic goals and they recommended ...
6
votes
1
answer
71
views
creating accounts with passportJs
I'm currently building an application using Passport and bcrypt for user authentication. I've created the registration part. Is there anything I could improve on? I'm still getting the hang of writing ...
4
votes
1
answer
5k
views
"Clean Architecture" design pattern with Node.JS and MongoDB
After some time poorly designing my web applications' backends (mixing database calls with the controller, etc.), I have decided to try the "Clean Architecture" approach.
In this example I have a ...
4
votes
3
answers
192
views
Find events associated with users on a certain date in MongoDB
I have this script which works perfectly but I experienced some delays because of these 2 for loops [i][j]. Is there any way to ...
2
votes
0
answers
113
views
Modeling mongoose schemas
I'm in the process of creating my first web app using node with mongodb on the backend. I could use some opinions on the schemas/models I've set up.
I have three schemas: User, Pet, Food. Here's the ...
3
votes
0
answers
416
views
Mern stack app on error handling, async await, try-catch and avoiding DRY in controller functions
I'm looking for a review of my backend code on how to keep it more DRY. I see a lot of repetition in validation part of email and password, also I need some advice on if I have used the try-catch and ...
2
votes
0
answers
119
views
Process data from mongodb and upload result to S3
I'm working on an AWS lambda function that take data from two mongodb databases, find the matching records between two collections by 'id' and calculate each record commission by fixed rate. Then ...
1
vote
0
answers
50
views
Store tweets to a local MongoDB server
I use NodeJS along with the MongoDB NodeJS Driver to store tweets into my local MongoDB server. In the following setup, mongos insertOne method gets invoked quite ...
2
votes
0
answers
113
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 ...
4
votes
0
answers
412
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:
...
4
votes
1
answer
698
views
Enhancing search using Fuzzy Logic in NodeJS
Brief Description:
In my NodeJS Application, I have a model called User.
User.js
...
2
votes
2
answers
2k
views
Retrieve a city list for a country and state
The code below is working properly but how do I make this code faster and more efficient. How do I perfect this code?
Let's assume I have 1000 country, state and city records in a mongodb collection. ...
2
votes
0
answers
733
views
jQuery datatables data rendering from mongodb
I am using jQuery data Tables server processing to show some data to user. The documentation instructs that the response that the server sends must have this data:
...
0
votes
1
answer
38
views
Node.js Data-Completion script
Following task:
Customer-data, given in a JSON-file, have to be completed with additional address-data. Given in a second JSON-file.
Then these data-stock has to be saved into a MongoDB-database.
...
1
vote
1
answer
55
views
Creating Mongoose model
I'm creating a Mongoose model for a web service. I have a secondary index on facultyId because majority of the reads would want to search by ...
2
votes
0
answers
44
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 ...
0
votes
1
answer
40
views
Send Response To Browser without DB save confirmation
Just reviewing my own code and noticed that I'm saving info in the DB and WAITING for that to respond before I send info to the browser, although I'm wondering if it would be more performant to not ...
0
votes
1
answer
62
views
Running arbitrary number of mongo queries in nodejs
I am faced yet again with a callback headache:
Simply I need to return to the client the results of multiple mongo queries, the number of which I don't know in advance.
In short:
fetch the first ...
2
votes
1
answer
3k
views
Updating multiple collections
I'm currently building a MongoDB which has collections of 2 types:
A series of "dialog" collections
A collection storing the version numbers of each "dialog"
I'm looking to build an API, where-in I ...
1
vote
1
answer
73
views
Scoping and asynchronous function
I have the following code where I need to return an array of objects as a response that has values from the server. The objects are filled with the right values, but when they are pushed into the ...
2
votes
0
answers
89
views
Create a stream request for Transaction history by client id on Braintree vault
I have been trying to create a transaction history request from Braintree using a client ID on Braintree vault, and it took far too long to figure out how, so here is the code on server that I ...
2
votes
1
answer
5k
views
Mongoose / MongoDB schemas for blog posts and authors
I'm programming a model for a blog with authors and posts. I was following this doc: Mongoose Query Population
My concern is that the createPost function is inefficient.
Another option is to nest ...
1
vote
1
answer
250
views
Two similar MongoDB-querying functions to find distinct and non-distinct documents
I'd like to remove some of the repeated code in my mongo data access layer. The code is all the same except for these key areas:
Function signature parameters differ between ...
1
vote
1
answer
64
views
Loading information about a competition every time the page is loaded
I am using KeystoneJS to manage data and my APIs (which includes Node.js, MongoDB, and Express.js). It uses Mongoose to connect with MongoDB; Keystone queries are essentially the same as Mongoose ...
9
votes
1
answer
38k
views
Mongoose: find() and count() query
Background
I have a query in Mongoose that finds a set of objects, and then returns these said objects together with the total number of them:
...
5
votes
3
answers
229
views
Verifying requirements before deleting a user-parent-student-school relationship
I am new to node, after I finished my APIs I realized that all of them are a mess, and are a callback hell, this forced me to learn about promises, now it was all good until I faced an API that has ...
2
votes
0
answers
175
views
Rewrite two mongo queries to aggregation
Here is a code block I have:
...
2
votes
0
answers
47
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
0
answers
151
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....
1
vote
2
answers
994
views
Avoiding nested callbacks when using MongooseJS
I'm diving into the world of nodejs and mongo. I am playing around with a simple app that uses MongooseJS to talk to Mongo. I have been looking at examples and some GitHub projects for references, but ...
3
votes
1
answer
53
views
'join' MongodDB collections with a for loop
This is a very simplified version of my query. Is it acceptable to join the two collections for the client with the use of for loops?
There could be up to 2,000 books, which also means there could be ...
2
votes
0
answers
397
views
Node.js stream of objects from MongoDB
I have a collection inside MongoDB with thousands of documents. A document should be processing depending on some logic. To make the point simple, I suppose here there is a field ...
4
votes
0
answers
2k
views
Mongoose schema for products and social media posts
Here is my current schema:
Brand:
...
3
votes
0
answers
87
views
Knowledge base app using MEAN stack
I've been working on an app based on the MEAN Framework. I have got the app working but I just wasnt sure whether my coding structure and standard was good enough, meaning does it adhere to the ...
2
votes
0
answers
107
views
Properly updating multiple MongoDB documents with Angular
In the app I'm creating, when a user upvotes a post, the post should be upvoted, as well as the user that wrote the post. But this updates two MongoDB documents. This presents a number of issues. I'll ...
1
vote
1
answer
2k
views
mongodb query in waterline,sailsjs
Because it is a lot of code, I don't want to ask for details what is wrong, but want to ask about review what can be changed in approach to this.
This is controller that make query:
It grabs data ...
6
votes
1
answer
1k
views
Updating state with React
I am creating a blog using React, MongoDB, Express and Node. I have three components: App, List, and Item. The item is a blog post; the list is a list of the blog posts, and the app includes a place ...
8
votes
1
answer
78
views
Retrieving StackExchange sites and tags
I have setup agenda tasks to periodically retrieve and possibly insert new SE sites and tags in my MongoDB database.
Some things that bother me in particular:
Lots of code duplication
No string ...
2
votes
0
answers
35
views
Modify records at one time
Do you think this works well? I.e, do I need to close the database connection at the end? The goal is to be able to upsert and delete many records in one shoot.
Here is is an example HTTP POST ...
3
votes
1
answer
268
views
Realtime chat service
I am new to Node.js and Socket.io. I implemented a realtime chat service that has a chatroom feature. When the actual product is launched, there will be at least 200 concurrent users with 50 groups of ...
2
votes
1
answer
7k
views
Node.js Paging with Mongodb
I want to create variable paging on Node.js with MongoDB. I use MongoJS on client side create a request:
...
2
votes
2
answers
175
views
SQL Server to MongoDB Template
Looking for feedback on a set of templates I've just created. I'm planning on converting them to Yeoman but want to make sure they're ready for prime time before doing so. They are currently in ...
2
votes
0
answers
999
views
Log my external IP address using NodeJS
I've been learning NodeJS recently, and have a small program to get the external IP address on my home network from fugal.net, compare it to the previous IP address, and if there is a change update ...