These are chat archives for Automattic/mongoose

Jul 2017
Julian Claus
Jul 16 2017 04:58
@AdelMahjoub is it possible to define this behavior automatically at every find event?
I don't want to send the _id to my client.
Paul "Joey" Clark
Jul 16 2017 07:25
@ndabAP Instead of model.find(query) you could use julianFind(model, query).
That might be useful again in future, the next time you want some custom behaviour for all finds.
Julian Claus
Jul 16 2017 08:17
@joeytwiddle that sounds like a good idea :+1: But there is no "native" way?
Paul "Joey" Clark
Jul 16 2017 11:15

Not that I know of.

The _id is usually kept so that .save() can work.

By the way, an alternative to .toObject() on the document is .lean() on the query.

Amir Braham
Jul 16 2017 11:23
hi everyond
how can I store a file in a schema
Jul 16 2017 11:27
@ndabAP you can define static methods on the Schema, check the instance methods section