These are chat archives for Automattic/mongoose

7th
Apr 2016
Maxim Yaskevich
@myaskevich
Apr 07 2016 13:41
Hi guys. Is mongoose@4.3.7 supposed to work with mongodb server 2.6 well?
LeonineKing1199
@LeonineKing1199
Apr 07 2016 15:09
I think I'm using Mongo 3 and it works fine.
tl;dr Yes it should @myaskevich
Maxim Yaskevich
@myaskevich
Apr 07 2016 15:35
@Nepoxx thanks
Pier-Luc Gagnon
@Nepoxx
Apr 07 2016 15:35
yw
David González
@davigonz
Apr 07 2016 16:28
Hi, I have a problem when I try to find an object id in object ids array
It returns an empty array
I have two Mongoose schemas:
var EmployeeSchema = new Schema({
    name: String,
    servicesProvided: [{
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Service'
    }]
});
and
var ServiceSchema   = new Schema({
    name: String
});
When I run this code
Employee
.find(
    { servicesProvided: req.params.service_id }
)
.exec(function(err, employees) {
    if (err) {
      console.log(err);
        res.send(err);
    }
    else{
        res.json(employees);
    }
});
It returns an empty array and I've tried a lot of different things but it seems anything works
Any idea? Thanks
David González
@davigonz
Apr 07 2016 16:35
I'm using Mongoose 3.8.31 with TingoDB and Tungus
Valeri Karpov
@vkarpov15
Apr 07 2016 18:05
@vladotesanovic not necessarily the case, sometimes you need multiple callbacks, just callbacks are good for making sure you aren't doing too much work :) haven't seen any case where async/await is really useful since co+yield does the same thing today
LeonineKing1199
@LeonineKing1199
Apr 07 2016 18:08

haven't seen any case where async/await is really useful since co+yield does the same thing today

I actually kind of feel the same way... Because there is co() and co integrates freakishly well into existing Promise-based code, I'm not that excited for async/await anymore...

Valeri Karpov
@vkarpov15
Apr 07 2016 18:08
@davigonz no guarantee that mongoose will work with tingodb. If you can reproduce this issue with mongodb proper, open up an issue on github please. Sorry to be unhelpful, but it's tricky enough to support multiple versions of mongodb, adding tingodb into the mix would be a lot of extra work for marginal benefit
@LeonineKing1199 yeah after Object.observe() got dropped and ES2016 ended up being essentially a no-op I'm really disinterested in the TC39 proposals in general
other than the pipeline operator and maybe AsyncIterator, nothing that's being considered for ES2017 is really interesting
LeonineKing1199
@LeonineKing1199
Apr 07 2016 18:11
Hmm... Do you have any relevant links to read about AsyncIterator?
honestly I think more general coroutines would solve all these problems, the only reason that I'm interested in AsyncIterator is cases like https://github.com/vkarpov15/dookie/blob/master/index.js#L149-L178 where I really just want some way to make an iterator that can do stuff like "loop over all mongodb collections, for each collection loop over every document"
of course, AsyncIterator looks like it depends on async/await, which is boooo
Pier-Luc Gagnon
@Nepoxx
Apr 07 2016 18:15
what's the pipe operator?
Valeri Karpov
@vkarpov15
Apr 07 2016 18:19
basically like _.chain() as an operator. https://github.com/mindeavor/es-pipeline-operator lowercase(capitalize(getBody(req))) can be written as req |> getBody |> capitalize |> lowercase
Pier-Luc Gagnon
@Nepoxx
Apr 07 2016 18:20
well, it's nice to have I guess, but like you said, meh, I wouldn't write a novel on it :P
Valeri Karpov
@vkarpov15
Apr 07 2016 18:20
it's one of the few proposals for TC39 that aren't user-land libraries thumping their chests about how awesome they are (e.g. observables, promises, asynciterator, etc. etc.)
oh and zones
this is exactly why I always hated the idea of promises in ES2015, because now every user-land library wants to be part of core JS
(but I also love the idea of promises in ES2015 because finally, some standardization, after the fragmented nightmare that was the promise lib landscape in 2014)
and actually, I could probably write a novel on why the pipeline operator is so sweet :)
for one thing, chaining would finally no longer require access to this
LeonineKing1199
@LeonineKing1199
Apr 07 2016 18:24
Hey vkarpov, you're one of the actual Mongoose people, aren't you? I think I've seen your name on the github page... If you are, just wanted to say that Mongoose is pretty sweet :)
Valeri Karpov
@vkarpov15
Apr 07 2016 18:25
I guess I am, thanks :)
LeonineKing1199
@LeonineKing1199
Apr 07 2016 18:29
I know Automattic is also the producer of monk as well. What's the deal with Mongoose vs Monk? Is one "better" than the other?
Vlado Tesanovic
@vladotesanovic
Apr 07 2016 18:38
@vkarpov15 Yes, but using TS in long term is better than co + yield. Once when ES7 implement async await, it will be just matter of compilation.
LeonineKing1199
@LeonineKing1199
Apr 07 2016 18:41
Well, I wouldn't hold my breath on ES7
looks better than callbacks :)
Pier-Luc Gagnon
@Nepoxx
Apr 07 2016 18:48
I still prefer promises :P
Vlado Tesanovic
@vladotesanovic
Apr 07 2016 18:48
i am not anti callback guy, but this looks good
this is promisses in background
it is compiled to promisses
Compiled
LeonineKing1199
@LeonineKing1199
Apr 07 2016 18:51
Oh wow, it's going to be super easy to switch from co to async/await
Valeri Karpov
@vkarpov15
Apr 07 2016 19:40
yeah they're really interchangeable. Most transpilers basically convert async/await to co/yield anyway. I've never been a big fan of TypeScript TBH, it's a brilliantly engineered solution to a problem that JS doesn't really have
Vlado Tesanovic
@vladotesanovic
Apr 07 2016 19:45
@vkarpov15 :D i will quote your sentence it's a brilliantly engineered solution to a problem that JS doesn't really have
simply brilliant :)
anyway, TS help you to write shorter and more accurate ( types ) code, for me
LeonineKing1199
@LeonineKing1199
Apr 07 2016 19:49
I agree though, JS problem was never typing. JS is literally what generic programming wants to be.