/node_modules/mongoose/lib/plugins/idGetter.js
https://bitbucket.org/coleman333/smartsite · JavaScript · 26 lines · 14 code · 5 blank · 7 comment · 4 complexity · b3fa2a55209076a62743e6afdca9a4e4 MD5 · raw file
- 'use strict';
- /*!
- * ignore
- */
- module.exports = function(schema) {
- // ensure the documents receive an id getter unless disabled
- var autoIdGetter = !schema.paths['id'] &&
- (!schema.options.noVirtualId && schema.options.id);
- if (autoIdGetter) {
- schema.virtual('id').get(idGetter);
- }
- };
- /*!
- * Returns this documents _id cast to a string.
- */
- function idGetter() {
- if (this._id != null) {
- return String(this._id);
- }
- return null;
- }