These are chat archives for Automattic/mongoose

11th
Nov 2018
Stansbery
@jstansbe
Nov 11 2018 18:49
Is there a place where i can test out and practice queries on actual data?
Berian
@chaiwa-berian
Nov 11 2018 20:11
Hi everyone. Would you kindly help me understand why none of the below mongoose.connection events are getting fired if the database connection gets closed while the app is running? I have tried the connection.on('disconnected'), connection.on('connected'), and connection.on('reconnectFailed'). I am also wondering why the mongoose.connection.readyState is always 1 if the App was connected to the database at startup and remains so even if I disconnect the database!
Berian
@chaiwa-berian
Nov 11 2018 20:24
@jstansbe If you have mongodb installed on your computer, you should be able to test your queries using the mongo shell. To run mongo shell, use the following command: mongo and then you can try out all the mongodb/mongoose queries on the shell console.I hope I understood you question! :)
Stansbery
@jstansbe
Nov 11 2018 21:07
The shell has no code hints/ or autospacing ?
Stansbery
@jstansbe
Nov 11 2018 22:10
How can i add a reference to another comment ?
comment { 
       _id: assignedByDb, 
       //   .. other props
        parent: { type: Schema.Types.ObjectId, ref: 'Comment', required:false }
 }
Stansbery
@jstansbe
Nov 11 2018 23:39
I got it! my ref was using the incorrect name, after using the name from the model it works