These are chat archives for Automattic/mongoose

3rd
Jan 2018
Nick Karnik
@theoutlander
Jan 03 2018 00:09
@threads13 I would suggest following a tutorial online … your code was working. I’m not sure what you’re doing on your end. You have the concept down, so try to debug it.
If nothing is getting stored, make sure you’re passing it data …
in the debugger you can verify that
mark it as required
and validator should fail
Jacob Hoke
@threads13
Jan 03 2018 00:10
ok - thanks
Nick Karnik
@theoutlander
Jan 03 2018 01:40
@Paikz look into the populate method of mongoose
Philip Esmailzade
@Paikz
Jan 03 2018 14:36
@theoutlander thanks for the pointer, solved it with virtual populate
Nick Karnik
@theoutlander
Jan 03 2018 16:07
@Paikz :+1:
@acao I haven’t used it, but it looks quite interesting. Although, I just noticed that the production version of mlab supports that inherently. Have you used that package?
Kev
@lineus
Jan 03 2018 17:11
with regard to removing a doc from an array of mongoose sub docs: in the example from the latest mongoose documentation it shows what appear to be synchronous calls to the remove function and subsequently the save function. When I call remove in the manner demonstrated in this way it returns a promise and the save doesn't affect anything. Am I missing something about the way the example is written (or something about mongoose in general) that allows the example to work? http://mongoosejs.com/docs/subdocs.html
Kev
@lineus
Jan 03 2018 17:18
fwiw, I was able to remove documents using the optional callback or by using the promise. I'm just trying to understand if I missed something so I can stop wondering about all the things I don't understand.
Nick Karnik
@theoutlander
Jan 03 2018 20:08
@lineus can you share some code where you don’t understand something?
Kev
@lineus
Jan 03 2018 22:42
parent.children.id(_id).remove();
parent.save(function (err) {
  if (err) return handleError(err);
  console.log('the subdocs were removed');
});
Kev
@lineus
Jan 03 2018 22:51
typeof parent.children.id(_id).remove() is a promise. I'm wondering how the save operation in the example is supposed to run after the promise is fulfilled. I'm new to just about everything related to javascript, promises, and mongoose, so I assume I'm missing something obvious.
thanks for your time @theoutlander