PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1'use strict';
 2
 3/*!
 4 * ignore
 5 */
 6
 7module.exports = function(schema) {
 8  // ensure the documents receive an id getter unless disabled
 9  var autoIdGetter = !schema.paths['id'] &&
10      (!schema.options.noVirtualId && schema.options.id);
11  if (autoIdGetter) {
12    schema.virtual('id').get(idGetter);
13  }
14};
15
16/*!
17 * Returns this documents _id cast to a string.
18 */
19
20function idGetter() {
21  if (this._id != null) {
22    return String(this._id);
23  }
24
25  return null;
26}