I'm using Mongo Express to view my data in my MongoDB instance during development. I also use the connect-mongo module to store my sessions in MongoDB. For some reason, Mongo Express has difficulties parsing embedded documents created by connect-mongo. The indention doesn't quite work and quotes are escaped. Documents created in connect-mongo do work, as well as those created with mongoose.
Looks like connect-mongo stores its data as strings, rather than as embedded documents. You can try using the default MongoDB shell - mongo and confirm if it's the case.
Related
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
I tried a sample example of total.js for REST APIs and I noticed that its all using the NoSQL module. I need to convert this sample to work with MongoDB instead. Is it Possible to use mongoose for mongoDB to work in total.js
Yes and absolutely you can use Mongoose with Total.js. Only you need to rewrite processing of data in schemas, it's not hard. Try to look into the Mongoose documentation and start there.
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.
I am using mongo database with mongoose (ORM). I have a database that is working well with Express framework Application. Now I want to connect to this database with another Express Application.
Now here is the question,
should I make all mongoose models again in new project with Mongoose ? if not then what will be best option for this that we can use still use existing database mongoose.
I am assuming you are not serving the data via a REST API then. If you create a REST API for the mongoose models and then serve that data through URL's you won't have to create new models, rather you could just request the data via HTTP through GET, POST, DELETE, etc requests from the new express application.
If you want me to elaborate further, I can certainty do so.
I'm interacting with MongoDB with several drivers including PyMongo and Node.js Native MongoDB driver.
What I noticed is that when I do fs.put for GridFS storage from PyMongo it only sets few fields including UploadDate, but when I do fs.put for GridFS storage from Node.JS it also inserts additional fields to storage that I don't need including ContentType.
That may be good practice, but I dont want this field, how do I configure MongoDB insert to ignore insertion of this field when adding file to GridFS from Node.JS? According to docs you can either set it or it will use default ContentType (content_type).
How to not insert this field it all?
Well, seems like there's no support for this feature. So I just commented stuff for fields contentType and aliases in MongoDB Driver library for Node.JS. Its bad practice, but unfortunately there's no another option for that right now.