These are chat archives for Automattic/mongoose

24th
Oct 2015
James Lee
@uptownhr
Oct 24 2015 06:13
@vkarpov15 been searching a bit and not seeing anything obvious. Any resources on creating a Types plugin to add in additional attributes? For example, lowercase:true or trim: true is nice. Would like to add in custom ones. Something like transform to alphanumeric, which will remove all characters other than alphanum before saving.
i know i can do this on the pre_save hook but would love to easily define this on the schema
James Lee
@uptownhr
Oct 24 2015 06:33
also for "lowercase", if the data was already saved without htis flag, I'm seeing the retrieved documents post the addition of the lowercase flag doesn't translate the string. Is this expected?
Valeri Karpov
@vkarpov15
Oct 24 2015 16:22
@uptownhr there isn't a good guide out there, but https://github.com/mongodb-js/mongoose-autopopulate is a fairly simple example of how to use that pattern in a plugin
Valeri Karpov
@vkarpov15
Oct 24 2015 16:28
@dvideby0 no concrete plans yet, still fleshing that out. Check back on Twitter or https://github.com/Automattic/mongoose/wiki/5.0-Deprecation-Warnings for more info, but 5.0 is still a ways away :)