These are chat archives for Automattic/mongoose

18th
Aug 2015
Alberto Restifo
@albertorestifo
Aug 18 2015 08:17
@ericmartinezr wait, you said systemjs? Then maybe it's a problem with how you configured systemjs
Eric Martinez
@ericmartinezr
Aug 18 2015 15:10
@albertorestifo thanks for answering. If I use require('mongoose') in server.js it works fine, since it's the first file executed by nodejs, but if I use it inside any angular2 file it will fail. I suspect it has to do with something angular2 does with require, since it adds automatically '.js' and it cannot find it
I've found this MEAN stack thing, and for what I understand the "M" and the "A" communicate with each other through a REST API. But that seems too much... I mean, I would like to get access to mongoose in any part of my app, but maybe it's not possible.
James Lee
@uptownhr
Aug 18 2015 16:49
@ericmartinezr not familiar with systems but are you trying to load mongoose from angular?
Eric Martinez
@ericmartinezr
Aug 18 2015 16:50
Yes, angular2 to be more specific.
James Lee
@uptownhr
Aug 18 2015 16:50
hmm
i’m sure it is somehow possible but I doubt there is a simple approach
unless there is a step by step guide somewhere, i suggest against it. Unless you want to spend days figuring it out
Eric Martinez
@ericmartinezr
Aug 18 2015 16:51
I don't mind figuring out, but I haven't found anything yet. I've found a plugin called angular-bridge (or similar), but that's for angular1
I've tried something like this : "Node.js (in this part require works) -> Express (loads a template file) -> Template file compiled by ng2 -> Some ng2 component calls 'require'"
when I call 'require' from a ng2 component it fails, so there must be something in there
that requiere is not being called by node.js anymore
James Lee
@uptownhr
Aug 18 2015 16:58
to use require from the browser, you need to convert your node modules using browserify
Eric Martinez
@ericmartinezr
Aug 18 2015 17:04
Thanks @uptownhr I'll look into that
Keyton Stanier
@stanier
Aug 18 2015 19:04
Is there a way for me to call a custom static helper method from the return of another method?
For example document.find({ foo: 'bar'}).customFunction()
I assumed attaching my function to the documentSchema.statics object would allow this behavior, but it doesn't seem to work with anything the helper methods return
Keyton Stanier
@stanier
Aug 18 2015 19:13
Sorry, let me rephrase now that my head is a little clearer: is there a way to chain a custom method to a query