These are chat archives for Automattic/mongoose

16th
Dec 2016
Deepak Verma
@deepaknverma
Dec 16 2016 02:46
Hi! I am writting an CRUD module for my app. My issue is I have a sample db to start with. on app initalization I want to fetch all the collection from my sample database and create mongoose schema/models from it. Is there any api which i can call to get current collection schema
Paul "Joey" Clark
@joeytwiddle
Dec 16 2016 04:14
@deepaknverma I don’t think there is anything in Mongoose for that.
You can get the list of collections from Mongo with db.getCollectionNames()
But deriving a schema is non-trivial: What if some of the documents have inconsistent fields?!
I think StrongLoop’s LoopBack may have done some work on automatically deriving Schemas.
David Schaller
@davidrschaller_twitter
Dec 16 2016 15:54
Hello. I am using native promises with mongoose. For actions such as save, I am utilizing a catch block to handle errors. Are catch blocks ever necessary for 'find' actions? I am considering removing them as I am unable to trigger a catch condition when retrieving data. Thanks.
Kiran Kumar Chaudhary
@chaudharykiran
Dec 16 2016 16:39
How to relation one mongodb document with another using mongoose?
David Schaller
@davidrschaller_twitter
Dec 16 2016 18:30
If you have a User schema, in the other document, include an entry like this:
User-Id:         { type: Schema.Types.ObjectId, ref: 'User' }
Daniel Marin
@mdanro
Dec 16 2016 22:27
Hello guys, i want to store time series data in mongodb, the document should be more or less a bidirectional array something like data:{ rawdata:{0:{0-59: temperature_data},1:...23..} , how can i do that with mongoose is it doable
?