Tagged Questions
1
vote
0answers
37 views
Twitch chat bot using node, express, mongodb
I need help on truly understanding my self project. Javascript is a language I struggle the most with so I decided to create a project using Javascript. In my education I'm mostly familiar with C++, ...
0
votes
0answers
9 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 ...
0
votes
0answers
34 views
Optimizing a long Node.js POST request
The request below takes very long on slower internet connections and Heroku is throwing a Request Timeout error for many users. The API request is being made by ...
0
votes
0answers
18 views
Reuse MongoDB connection in Express application
So I think the title is pretty straightforward. I implement a client for MongoDB and I want to include it anywhere in my app and share the connection (not create it always or close it always).
So my ...
1
vote
1answer
24 views
Forcing array of promises to complete before returning
I'm making one call to a mongoDB database to fetch a list of existing collections and then looping through the collection list and fetching their document count.
All db methods are promises and i'm ...
2
votes
1answer
36 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
1answer
45 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 ...
1
vote
1answer
38 views
Mongoose query using conditional formatting and regex
I this the function createQuery is fully functionally, but I would like a review on it. I'm pretty sure this can be shorten and most important (improve performance). Any ideas?
...
1
vote
0answers
31 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 ...
2
votes
0answers
27 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 ...
1
vote
1answer
39 views
Finding unreferenced documents
I have a database containing at least 2 collections datagroup and data.
Each data document ...
1
vote
0answers
33 views
Handling MongoDB data for EJS file
I'd like to render mainly mongoDB data and an array. What I want to do is allow my EJS file to use the components inside the database.
...
0
votes
0answers
34 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 thought is that at the lines 34~37 will duplicate the posts. Another option is to ...
0
votes
0answers
22 views
Doing findOne with save or update the right way in nodejs mongoose
I am trying to understand the need for findone / save / update. In this case I try to find the message record. If there is none, then I create a new one. If there is already one, then I update some ...
0
votes
0answers
89 views
A URL Shortener with express/mongodb/nodejs
please give feedback on anything you think I could improve on. This is a URL shortener that I did from the freecodecamp challenges.
Here are some things I would like feedback on:
-My functions, do ...
1
vote
1answer
45 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
1answer
45 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 ...
1
vote
1answer
728 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
3answers
202 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 ...
1
vote
0answers
51 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 ...
3
votes
0answers
121 views
0
votes
0answers
371 views
Update document if it exists otherwise create a new document - Mongoose
As the question states when the user submits a form mongoose checks whether the document for that user already exists, if yes then pushes an object into the array. If it does not exist then it creates ...
2
votes
0answers
30 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
67 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
2answers
111 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 ...
2
votes
1answer
46 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 ...
0
votes
0answers
93 views
Get last n items from collection in order from least recent to most recent
I wanted to get the last n items from a MongoDB collection starting with the least recently added element (lowest id) and ending with the most recently added element. After that I want to stream them ...
1
vote
0answers
161 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 ...
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 ...
0
votes
0answers
127 views
Generating a random ObjectID
We want to ensure that certain documents in our DB get distributed well across the shards. Currently the documents are sharded by their _id, but they are often ...
1
vote
0answers
309 views
1
vote
0answers
46 views
MongoDB Per-Module Reusable DB Object With Reconnection Handled
This implementation was derived from the following requirements. I would like to learn that whether the implementation is clean enough, without memory leak and performance hit.
Requirements
Always ...
1
vote
0answers
54 views
Locate enteries to the nearest date selected
This code loops through a given range of dates and for every 5 minute iteration pulls up the last known records of the users in the database relative to that timestamp.
I'm trying to find a way to ...
2
votes
0answers
152 views
Managing modules in phone book app
This is a test app built with NodeJS, Express and MongoDB. This code is the main and complete JavaScript file. I would like suggestions on dividing it into different modules and making the main app.js ...
2
votes
0answers
70 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 ...
1
vote
0answers
889 views
2
votes
0answers
61 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
1answer
743 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 ...
5
votes
1answer
796 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 ...
2
votes
0answers
61 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 ...
0
votes
0answers
2k 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 ...
8
votes
1answer
67 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 ...
0
votes
1answer
297 views
Flattening a 2D array to use map/reduce
I have been trying to get better at functional programming, which includes understanding map/reduce. I wrote a function intended to fill an autocomplete with values. The challenge I was encountering ...
1
vote
0answers
129 views
Pulling data quickly from mongodb with node.js
I am currently struggling with a request I am making to my server that is taking more than 4 seconds! I cut out a lot of the cruft to hopefully make it easier to read. Excuse my horrible variable ...
2
votes
0answers
31 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
1answer
213 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
1answer
4k 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:
...
1
vote
0answers
28 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 ...
2
votes
2answers
154 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 ...
3
votes
0answers
41 views
Iterating a list to make API calls
I'm new to JavaScript and was hoping there was a cleaner way to write this. It's a block of code that looks at a group of documents in a collection (called Messages), and makes a call to the GitHub ...