Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [mongodb]

MongoDB is a scalable, high-performance, open source, document-oriented database. It supports a large number of languages and application development platforms.

2
votes
0answers
31 views

Flask-PyMongo best practices to manage a mongodb database using python

The functions below are from a class of slave function which interact with my mongo database. The purpose is to serve a Flask based API by responding with the appropriate data required along with the ...
0
votes
0answers
10 views

Grouping by multiple items in MongoDB Shell

I'm practicing MongoDB for an upcoming job interview and came across a query that works but seem incorrect. I'm trying to find the average price and average number of manufacturers grouped by the ...
0
votes
0answers
19 views

Yelp-like app for finding hangout places in Egypt

I've been learning web development for a while now and this is my first real application. It's an application you can visit when you're looking for a place to hang out, meet some friends or work. ...
1
vote
0answers
26 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 ...
-2
votes
1answer
73 views

How can I get this two functions into one

I have made some code in c#. I am currently developing a Gameserver so I have a function to update fields in the database. I also have a function to update the player-cash, but its like almost the ...
0
votes
1answer
36 views

Decompose big service class into small classes

Need to parse MongoDB collection and save parsed data into different postgres tables. MongoDB stores documents with different type field, for each type need to ...
0
votes
1answer
20 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. ...
0
votes
0answers
33 views

Implementing storage with MongoDB

I need to write REST interface to MongoDB. Help me please to improve the architecture. The program's main goal: respond to HTTP requests, store big files in Mongo, send file metainformation, etc. I ...
0
votes
0answers
30 views

Mongo query to pymongo compatible query

I am trying to make mongo queries work directly with pymongo for that I wrote a little script. But I am not happy with my convert_iso_date_to_datetime it feels ...
0
votes
0answers
61 views

What's the best way to create reference documents in Mongoose?

I have some schemas as below. The flow of creating data are User => SaleOrder => SaleItem. The SaleOrder contains the array of SaleItem, so after creating SaleItem document, I invoking ...
1
vote
0answers
32 views

Refactoring several mongoose models to similar collections [closed]

I have several collections that have the same documents type, except for the language. Let's say imagesES, imagesEN, imagesFR, and so on.... I just thought about definig just one schema, but also one ...
1
vote
0answers
232 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 ...
4
votes
1answer
66 views

Resource closing in a promise chain

This is some code that fetches a result from a database. It connects, makes a query, processes the query, then has to close the DB (under all possible code paths) and return the result. It seems ...
1
vote
1answer
36 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
0answers
30 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
1answer
36 views

Mongo command to add a field to all documents in a collection

This code appends a boolean column to all documents in the birds collection. ...
1
vote
0answers
621 views

Python class to save objects into MongoDB

I am new in Python, and I am writing a Python class representing a calendar entry, each entry contains 2 properties: the date and its type, which can be weekday/weekend/legal holiday/paid holiday/...
0
votes
1answer
29 views

Repository layer for MongoDB

I've implemented a quick and dirty repository to save and insert users to a MongoDB. As you can see, it just inserts one and finds one. Not a rocket. The thing is I don't really know what are the ...
0
votes
1answer
27 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 ...
1
vote
0answers
63 views

Switch MongoDB databases dynamically per user

I'm doing a POS (point of sale) as Saas with React in the frontend, NodeJs in backend (API Rest) and MongoDB as the database. I've finished a basic program and now I want any registered user to have ...
2
votes
0answers
213 views

MongoDB UPSERT in Python

I have code that scans our multiple SANS and inserts each file into a mongoDB. The code also checks the database first and if the document exists it updates the document. These are huge file systems ...
1
vote
0answers
224 views

Twitter clone in NodeJS

I have written a small Twitter clone using NodeJs, MongoDB and RabbitMQ, which you can find here. I started this project because I wanted to get a better understanding of both NodeJs and Rabbit. I'm ...
1
vote
0answers
358 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
1answer
43 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
1answer
890 views

Java MongoDB client as a singleton

Is below code a valid Singleton design pattern for Mongodb in Java? Please suggest any improvements. ...
1
vote
0answers
223 views

MongoDB database abstraction

Backstory The company I work, we have the code below that acts as an abstraction of our database layer, which is mongoDB. This ensures our other code is not too dependent on the database. This is ...
0
votes
0answers
51 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 ...
1
vote
0answers
497 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
0answers
24 views

Retrieving the count of users with complete and incomplete profiles

Problem I have to display the count of total users with Incomplete and Complete Profiles. Incomplete Profiles are those which will have 4 fields of String type. ...
2
votes
1answer
48 views

Generating Report Data in CSV format for various cases

I have to show report data for various cases in text-csv format as soon as the user click's on the given URI's. The given cases are: End_Customer Data Incomplete Profiles. Total Connections Below ...
1
vote
1answer
35 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
391 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
57 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
977 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
152 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
54 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
49 views

Finding unreferenced documents

I have a database containing at least 2 collections datagroup and data. Each data document ...
3
votes
1answer
379 views

Bash script to deploy a mongodb cluster on local machine

I recently wrote a small script to deploy a mongodb cluster on a single machine. The cluster is composed of : 3 configurations server that holds the same informations (they are replicas ) 2 shard ...
1
vote
0answers
243 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. ...
3
votes
0answers
288 views

Populate MongoDB with random documents using a Go channel

I recently created a small app in Go that generates random bson documents and insert them in a database (MongoDB). See this question for details. After doing some profiling, I realised that garbage ...
0
votes
1answer
967 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
1answer
32 views

Python script to identify regex matches in all subdirs and write dict of matches to MongoDB

I've been attempting to teach myself Python over the past couple of months and have been setting myself practical challenges to learn different aspects of the language. I have a deep structure of ...
6
votes
2answers
109 views

MongoDB Perl Wrapper

I'm trying to create a custom "mongodb perl wrapper". I created the following perl module, which local on my machine runs. My questions to the community are: Would you create the module different? Do ...
2
votes
1answer
96 views

Aggregate query for drawing temporal statistic

I used to write simple Mongo queries, but this time I had to create an aggregate query. The purpose is to draw temporal statistic on the main page of my web app. I'm not confident about his ...
1
vote
1answer
89 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
2answers
50 views

Persist relation to a class (and not a class instance) in Ruby on Rails with Mongoid

Assume my users can subscribe to several plan_types. I want to define those plans as classes, and be able to keep, for each user, a reference to a subscription_plan and also a presubscription_plan. ...
2
votes
1answer
422 views

Start, stop and restart script for a MongoDB server

I have created an start, stop, restart script for a unix-mongodb-server. It would be nice if you could look over my code and give me some helpful hints on what I could change. I tested the script ...
1
vote
1answer
100 views

Models in a Simple PyMongo-based Blogging Web App without ORM/ODM

I am currently using PyMongo + Flask for building a simple blogging application. I am not using any kind of ODM, instead I decided to use PyMongo directly. I need to know how to improve my code since ...
0
votes
1answer
94 views

List User Online Status

I'm using Rails with MongoDB for database. In my apps I have 1 action for displaying list of users. User has name, image, ...
1
vote
1answer
49 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 ...