HTMLify
VirtualOptions.js
Views: 6 | Author: cody
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | 'use strict'; const opts = require('./propertyOptions'); class VirtualOptions { constructor(obj) { Object.assign(this, obj); if (obj != null && obj.options != null) { this.options = Object.assign({}, obj.options); } } } /** * Marks this virtual as a populate virtual, and specifies the model to * use for populate. * * @api public * @property ref * @memberOf VirtualOptions * @type String|Model|Function * @instance */ Object.defineProperty(VirtualOptions.prototype, 'ref', opts); /** * Marks this virtual as a populate virtual, and specifies the path that * contains the name of the model to populate * * @api public * @property refPath * @memberOf VirtualOptions * @type String|Function * @instance */ Object.defineProperty(VirtualOptions.prototype, 'refPath', opts); /** * The name of the property in the local model to match to `foreignField` * in the foreign model. * * @api public * @property localField * @memberOf VirtualOptions * @type String|Function * @instance */ Object.defineProperty(VirtualOptions.prototype, 'localField', opts); /** * The name of the property in the foreign model to match to `localField` * in the local model. * * @api public * @property foreignField * @memberOf VirtualOptions * @type String|Function * @instance */ Object.defineProperty(VirtualOptions.prototype, 'foreignField', opts); /** * Whether to populate this virtual as a single document (true) or an * array of documents (false). * * @api public * @property justOne * @memberOf VirtualOptions * @type Boolean * @instance */ Object.defineProperty(VirtualOptions.prototype, 'justOne', opts); /** * If true, populate just the number of documents where `localField` * matches `foreignField`, as opposed to the documents themselves. * * If `count` is set, it overrides `justOne`. * * @api public * @property count * @memberOf VirtualOptions * @type Boolean * @instance */ Object.defineProperty(VirtualOptions.prototype, 'count', opts); /** * Add an additional filter to populate, in addition to `localField` * matches `foreignField`. * * @api public * @property match * @memberOf VirtualOptions * @type Object|Function * @instance */ Object.defineProperty(VirtualOptions.prototype, 'match', opts); /** * Additional options to pass to the query used to `populate()`: * * - `sort` * - `skip` * - `limit` * * @api public * @property options * @memberOf VirtualOptions * @type Object * @instance */ Object.defineProperty(VirtualOptions.prototype, 'options', opts); /** * If true, add a `skip` to the query used to `populate()`. * * @api public * @property skip * @memberOf VirtualOptions * @type Number * @instance */ Object.defineProperty(VirtualOptions.prototype, 'skip', opts); /** * If true, add a `limit` to the query used to `populate()`. * * @api public * @property limit * @memberOf VirtualOptions * @type Number * @instance */ Object.defineProperty(VirtualOptions.prototype, 'limit', opts); /** * The `limit` option for `populate()` has [some unfortunate edge cases](/docs/populate.html#query-conditions) * when working with multiple documents, like `.find().populate()`. The * `perDocumentLimit` option makes `populate()` execute a separate query * for each document returned from `find()` to ensure each document * gets up to `perDocumentLimit` populated docs if possible. * * @api public * @property perDocumentLimit * @memberOf VirtualOptions * @type Number * @instance */ Object.defineProperty(VirtualOptions.prototype, 'perDocumentLimit', opts); module.exports = VirtualOptions; |