Referring manually created collection stored in mongo atlas from node js - node.js

i am currently creating a nodejs app that deals with huge data. I created a table(.csv file) in excel and then converted it to to JSON file and added the document to MongoDB Atlas under the collection
players. The collection is huge, hence i did not create the collection inside from Node.JS. Now I want to refer to the fields inside the MongoDB collection from my Node.JS application and using it as a model..
how to solve this problem.....

You can just create a mongoose schema and model as you do normally. But, name the model player so that it points to your mongodb's players collection.

Related

How do I exactly use the mongodb partialFilterExpression in my node application?

I am using nodejs, mongodb as my data base and mongoose. I wanted to use partialFilterExpression to handle issue with mongodb saving null as unique value when I set unique to be true and a user provides an empty value for that object.
I am using mongodb Atlas. I didn't install mongodb in my local machine. Methods that I have seen online on how to use partialFilterExpression didn't explain if it is possible for developers who are using mongodb Atlas. I have tried using it inside my mongoose schema but it didn't work.
Can partialFilterExpression be used inside mongoose schema? If no, how can I use it with my mongodb Atlas database system?
Thanks

How mongoose schema relates to db in CRUD operations

How does fetching records from mongoose find() and updating records with updateOne work exactly.
I am unable to find it on social media..
When a GET request arrived to route handler. Will data fetch from db and maps to schema or will it get records directly from db?
Please explain the proper workflow. What happen when request arrives and how the mapping from db to schema works in CRUD?
Making the assumption that you are also using a framework like expressjs, a GET request does not go directly to mongodb
within a framework like express, you write a handler to handle GET/POST/PATCH/DELETE/PUT etc. within each of those routes you would write your code to interact with mongoose (mongodb)
for reference here is a
basic entry level NODEJS app

Adding photos to users collection in mongodb

I am new to using mongodb, I have a collection of users, I want every user to upload some of their photos. So, I am thinking of creating property called images for every user document. this would be an array of images. However, I don't know if it's applicable or not, or how to do so. Any ideas? I am using node.js
There multiple libraries that are created to help store images in a MongoDB database. You can see some at this question: Store images in a MongoDB database
Also, for good design, you should consider having the images property containing IDs that correspond to the image, instead of the actual images themselves; it would be named imageIds.

Can I use MongoDB schema model for defining IndexedDB indexes?

I am creating a progressive web app that that is using NodeJS and Express as backend, MongoDB as server, and IndexedDB for storing data locally when offline.
Currently I have defined some Mongoose schema models, and my application is suppose to fetch the data from my MongoDB server and store it into my local IndexedDB when the application goes online. Is it possible to make my IndexedDB's indexes follow the format of my Mongoose schema models, so that if I made some changes to the models, the IndexedDB's indexes will follow the changes as well.
The question is not so clear, an example would have help. But from what I understand, you want to be able to change the schema in MongoDB without breaking the documents saved in IndexedDB and you don't want to update the schema in IndexedDB each time you change the schema in MongoDB. You could use PouchDB which can use IndexedDB behind the scene and it would you to match the same schema as in your MongoDB. PouchDB integrates very well with MongoDB. Thus, if you model changes in MongoDB, when the document is eventually saved on PouchDB (IndexedDB), the document would have the same schema! For your info, PouchDB is the equivalent of MongoDB but in a browser.

how to create a dynamical collection on Mongodb using node js

i mean how to create a dynamical collection on Mongodb using node js, (equivalent to add column with a name chosen by user on Mysql).

Resources