UNPKG

802 BJavaScriptView Raw
1'use strict';
2
3const clone = require('../helpers/clone');
4
5class PopulateOptions {
6 constructor(obj) {
7 this._docs = {};
8
9 if (obj == null) {
10 return;
11 }
12 obj = clone(obj);
13 Object.assign(this, obj);
14 if (typeof obj.subPopulate === 'object') {
15 this.populate = obj.subPopulate;
16 }
17
18
19 if (obj.perDocumentLimit != null && obj.limit != null) {
20 throw new Error('Can not use `limit` and `perDocumentLimit` at the same time. Path: `' + obj.path + '`.');
21 }
22 }
23}
24
25/**
26 * The connection used to look up models by name. If not specified, Mongoose
27 * will default to using the connection associated with the model in
28 * `PopulateOptions#model`.
29 *
30 * @memberOf PopulateOptions
31 * @property {Connection} connection
32 * @api public
33 */
34
35module.exports = PopulateOptions;
\No newline at end of file