These are chat archives for Automattic/mongoose

10th
Mar 2016
Ian Maddox
@ianmaddox
Mar 10 2016 01:07
What's best practice to make the connection blocking? I've tried ES6 promises, but I keep getting back an empty object. The connection process doesn't complete until after the rest of the script has gone pear shaped because the .then() chain just kept on trucking.
James Lee
@uptownhr
Mar 10 2016 08:12
@ianmaddox you can't make the connection blocking.
you'd need to perform the other steps inside your then block
Khalil Zaidoun
@KhalilZaidoun
Mar 10 2016 09:52
Hello, can anyone tell me how to use 'Schema.Types.ObjectId' ? thx
Serbay Arslanhan
@sarslanhan
Mar 10 2016 12:26
hey @vkarpov15 and other contributors, i want to start contributing to the project. i picked a Automattic/mongoose#3953 to address. however while analyzing the codebase, i noticed that this issue might be more related to mquery repo. so, should i move this issue to mquery repository or is there any other way you could think of to do this in mongoose? if can you point me to the right direction here, it would be great. thanks
James Lee
@uptownhr
Mar 10 2016 12:37
@sarslanhan does mongoose use mquery?
Serbay Arslanhan
@sarslanhan
Mar 10 2016 13:27
@uptownhr from my understanding by looking at the query constructor, yes it does
Renader
@Renader
Mar 10 2016 14:18
Guys, how to structure my app the best? I have models and anything else is right now in my express routes. Isn't it better to have a Service for each model? And a Class?
How would i structure it then
(i could use typescript for better class handling)
just dont know what belongs where
James Lee
@uptownhr
Mar 10 2016 14:19
@Renader checkout my boiler plate project, http://github.com/uptownhr/hackathon-starter-lite
and see how Models are used
Renader
@Renader
Mar 10 2016 14:25
Cool thanks
How would i continue if i wanted to add typescript classes?
I'd have to specify a interface for the model
How declare that the dataset is type of class when i want to use methods? or i call anytime new class(mongoseQueryOuput) ?
James Lee
@uptownhr
Mar 10 2016 17:35
i don't have experience with typescript
Ian Maddox
@ianmaddox
Mar 10 2016 19:04
@uptownhr I was able to get the connect to be blocking by including it in a module and exporting the call to mongoose.model()