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.

Filter by
Sorted by
Tagged with
0
votes
0answers
25 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
0answers
38 views

which code is optimize in ruby on rails with mongoid? (By relation chaining parent to child or by foreign key of child) [closed]

So, I have two models in my ruby-on-rails + mongoid application - client.rb class Client has_many :users end user.rb <...
1
vote
0answers
18 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 ...
3
votes
0answers
29 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
1answer
60 views

Enhancing search using Fuzzy Logic in NodeJS

Brief Description: In my NodeJS Application, I have a model called User. User.js ...
2
votes
2answers
68 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
0answers
53 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: ...
4
votes
1answer
42 views

Get data and send mail script

I wrote a script using Python that gets data from several sources (news sites, Twitter, Yahoo), puts it into a dict and then formats it as a string to be sent through email. I wonder if there is ...
1
vote
1answer
79 views

Check mongodb status is running or not

I have written a program in golang which checks the mongodb is running or not using commands. But I'm not sure that the program is sufficient or there is something that needs to change in the program. ...
2
votes
0answers
542 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 ...
1
vote
0answers
66 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
78 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
43 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
24 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
0answers
583 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
77 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
40 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
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 ...
1
vote
1answer
39 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
1k 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
47 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
31 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
77 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 ...
3
votes
0answers
731 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
306 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
566 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
48 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
2k 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
303 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
67 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
638 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
28 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
49 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
39 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
1k 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
65 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
2k 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
216 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
74 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
516 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
439 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
398 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
2k 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
42 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
119 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
318 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
178 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 ...
2
votes
2answers
60 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
656 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 ...