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.
185
questions
1
vote
0
answers
38
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 ...
2
votes
1
answer
28
views
Do you think it's a good schema.prisma?
i'm trying to learn backend with Next JS, and i'm using Prisma + MongoDB. I want to create a simple website with a user with a cart and some products. here my schema :
...
0
votes
1
answer
67
views
I have use this approch in my golang mongo REST APIs' DAO layer, need to clarify this is a good way or not
I have used this approach in my Golang MongoDB REST APIs' DAO layer, I need to clarify whether this is a good way or not, code is as follows,
...
5
votes
1
answer
185
views
Express.js blogging application
I have put together a blogging application with Express, EJS and MongoDB.
There is a public, front-end part and a dashboard. In index.js I have:
...
1
vote
0
answers
107
views
Whatsapp Bot using Mongodb
I have this Whatsapp bot made using Twilio and persistent with mongodb due to the nature of the logic I am following the code is become more of a cluttered and seems un-pythonic. It works fine as I ...
3
votes
0
answers
409
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 ...
1
vote
1
answer
84
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 ...
4
votes
3
answers
188
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 ...
1
vote
1
answer
74
views
Pulling images from a MongoDb database
I have a method that on click produces an excel file with information in it. I have been asked to pull images from the data base and add them within the excel file as well. This is how I am pulling ...
2
votes
2
answers
121
views
Change interface depending on if statement
I'm using fiber and mongodb. Field "field" is needed to obtain certain data to unload the load on the database. If field "field" is empty, then needs to output all the data from ...
2
votes
1
answer
106
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
1
answer
940
views
MongoDB abstraction in Go with generics
I'm working on a new project with go. So I figured I would give this new feature a run (it's fun!). Although, I'm not sure I'm implementing this the way it's suposed to be.
I've read the following ...
0
votes
1
answer
1k
views
Mongodb connection retry
Created a MongoDB client which is handling the retry in case of server connection failure. Please review and how I can improve further.
...
1
vote
1
answer
91
views
Cleaning Kotlin method which returns the document name after the id
I'm just getting to know the possibilities of Kotlin and mongoDB.
I am writing a method that returns the name of the street after the ID.
Everything works, but I find it quite sloppy.
Empty String ...
5
votes
1
answer
205
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
1
answer
112
views
Archiving MongoDB data to S3, with retryable steps
I have a python script to archive some data (export from mongo to a local json file and then upload it to s3)
Is there a better way to implement/improve the current flow? Each step should be be ...
2
votes
2
answers
70
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.
...
4
votes
2
answers
810
views
Spring Boot API - Avoiding Concurrency issues
I'm still in the process of learning Java / spring and I think I'm getting better. Now at this point I'm able to build a rest api BUT I'm at a lost at how to ensure I've no concurrency issues . I've ...
1
vote
2
answers
4k
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
0
answers
138
views
Python/Mongo - Generating dummy data
I wrote below piece of code generating dummy data loaded to MongoDB.
2 issues :
1.customer class has subscriber class so it nested with one level customer--> subsciber.
I think i'm not doing right:
...
0
votes
1
answer
631
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?
...
4
votes
1
answer
236
views
Commands Object creation using chained Builder pattern
Context
As many of you may know I have a library that allows C++ objects to be converted into JSON/YAML/BSON automatically with a single declaration (see previous code reviews).
I am now (trying) ...
2
votes
1
answer
374
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 ...
3
votes
0
answers
182
views
Migrate customer and transaction data from CSV to MongoDB
I wrote a Java Spring Boot application with MongoDB that on every application start loads customer, account type and transaction details from CSV files to MongoDB. It has one end point that returns ...
5
votes
3
answers
19k
views
Get all followers and friends of a Twitter user
I'm trying to find my bug or any potential bottleneck that cause my program to be really slow. The script is to get all the followers and friends and save that in MongoDB.
...
2
votes
0
answers
736
views
mongodb RESTfull api in python using fastapi and mongoengine
So I wrote a a RESTfull api for a mongodb with python3.7, fastapi and mongoengine and id love to get feedback on how I should make my code more readable, clean, and dry.
basically there are 4 main ...
2
votes
1
answer
3k
views
Spring, Kafka and Mongo how to create a RestController
I'm learning how to use Kafka, I've never used something similar in the past. In my job I was required to create a POC using it and integrate it to Spring Boot and save information on MongoDB (because ...
1
vote
1
answer
153
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
118
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
69
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 ...
2
votes
0
answers
253
views
Simple Flask REST API to a MongoDB
I'm writing a simple REST API to my MongoDB using PyMongo (Python 3.7).
Each collection I have in the DB has a route (e.g http://the.api.url/collection_name ),
and every document under that collection ...
3
votes
1
answer
167
views
Python REST API and Mongo - Aggregation Pipeline/Stage classes
This has been my approach for "simplifying" MongoDB aggregation queries in a pythonic syntax - was my intent, at the very least:
...
4
votes
2
answers
236
views
MongoDB connection manager
I wrote a class for some MongoDB operations. So far I'm self-taught and mostly I follow the style from already existing code at my workplace (a startup).
We don't have a code-review culture, so I'm ...
1
vote
0
answers
1k
views
What's the proper way to do MongoDB aggregation query with optional parameters?
I have this api endpoint where i want to lookup a user or multiple users schedule and also specify the month or/and the day when doing the query. My code works, but i feel like there is a better, ...
2
votes
1
answer
1k
views
Import huge XML data set into MongoDB while parsing data
I am currently working with the Stack Exchange Data Dump - to be more precise - with the dumped Posts.xml data set from Stack Overflow.
What am I trying to achieve?...
2
votes
0
answers
76
views
Return aggregated values
It's the first time a write a non-trivial mongodb query, and I came up with one that does work, but is 123 lines long! Surely there must be a way to write it in a more concise way.
The purpose of the ...
3
votes
2
answers
83
views
Simple automation executing platform in Python
I'm building a platform like Rundeck/AWX but for server reliability testing.
People could log into a web interface upload scripts, run them on servers and get statistics on them ( failure / success).
...
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 ...
2
votes
0
answers
112
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 ...
1
vote
1
answer
3k
views
connection to mongodb in golang
I am building an API server in golang with mongodb. My main.go file looks something like this:
...
3
votes
1
answer
83
views
Speed up Python Script to populate MongoDB
How would I go about making this script much faster? Essentially it reads from a file and the slowest part is populating the words. In the words file there are over 100k words and I was looking for a ...
2
votes
0
answers
36
views
Representing LXC component configuration in django
I want to represent components of LXC in django; so I defined them in models: Container, Network, Profile and Devices where each one of them have a set of attributs, but when it comes to representing ...
1
vote
1
answer
31
views
Express error if agency not found middleware
In an api I'm building, I have multiple routes that require an agency to exist before any action is performed on the requested agency.
To avoid repetition I've written some middleware to check that ...
2
votes
0
answers
115
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 ...
2
votes
1
answer
2k
views
Python app-level document/record locking (eg. for MongoDB)
MongoDB does not provide means to lock a document (like SELECT FOR UPDATE in RDBMS).
There is a recommended approach to Isolate Sequence of Operations, which is ...
1
vote
1
answer
657
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. ...
3
votes
0
answers
211
views
Flashcard Website
In my endeavor to learn Angular, I've created a flashcard site with an F#/Mongo backend. As I'm new to Angular, I'm going to post everything; any and all feedback is welcome.
First, some pictures of ...
2
votes
0
answers
737
views
MongoQ - A Task queue system using Mongo
I've been using Beanstaldk (not Amazon's one) for years and loved the possibility to handle delays and priorities in the tasks, but I recently had to filters the tasks for specific reasons, and ...
7
votes
2
answers
3k
views
Insert 271 million records from text file to mongodb
I have 271 million records, line by line in a text file that I need to add to MongoDB, and I'm using Python and Pymongo in order to do this.
I first split the single file containing the 271 million ...
2
votes
0
answers
322
views
Synchronous use of Mongo-Scala Driver
The Mongo-Scala Driver (v2.6) currently only supports asynchronous operations, although my use cases often seem to lend themselves well to synchronous reads. This may be to block downstream code ...