These are chat archives for Automattic/mongoose

4th
Nov 2015
James Lee
@uptownhr
Nov 04 2015 00:04
with es6, shouldn't i be able to do {Model,Schema} = mongoose
given mongose = require('mongoose') ?
Luke A. Greenleaf
@gishmel
Nov 04 2015 00:19
think you could do import mongoose, {Model, Schema} from 'mongoose';
James Lee
@uptownhr
Nov 04 2015 00:26
got it
this works in node without transpilers right?
James Lee
@uptownhr
Nov 04 2015 00:54
@vkarpov15 auto-populate plugin is using schema.pre('find') ...
if i wanted to write an alphanum filter, would i hook into the pre events as well?
and is there an event for when a document is instantiated?
Sathya Narrayanan
@sourcepirate
Nov 04 2015 05:16
@vkarpov15 thanks for your suggestion.
Chris Adams
@chadams77
Nov 04 2015 06:26
quick question, if I have an object (o) and it's model has an array (ar) and a mixed object (mo), if I do o.ar.push(o.mo) will it automatically deep copy mo or do I need to do that myself?
Valeri Karpov
@vkarpov15
Nov 04 2015 17:18
@uptownhr re: plugins.mongoose, https://github.com/aheckmann/mongooseplugins
@uptownhr re: import in node, I'm pretty sure node doesn't support the import statement natively, at least in v4.0.x
and @uptownhr yep. To plug in to when a doc is instantiated, just call schema.queue() http://mongoosejs.com/docs/api.html#schema_Schema-queue (this is how pre/post hooks work)
@chadams77 I don't think it'll automatically deep copy, clone it yourself if you need it