You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Safe to do this even in the schemaFieldsOnly case because we assume there's no nested paths
3915
3941
constvalue=this._doc[key];
3916
3942
if(valueinstanceofDate){
3917
3943
ret[key]=newDate(value);
@@ -4064,6 +4090,7 @@ Document.prototype.$__toObjectShallow = function $__toObjectShallow() {
4064
4090
* @param {Boolean} [options.flattenMaps=false] if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`.
4065
4091
* @param {Boolean} [options.flattenObjectIds=false] if true, convert any ObjectIds in the result to 24 character hex strings.
4066
4092
* @param {Boolean} [options.useProjection=false] - If true, omits fields that are excluded in this document's projection. Unless you specified a projection, this will omit any field that has `select: false` in the schema.
4093
+
* @param {Boolean} [options.schemaFieldsOnly=false] - If true, the resulting object will only have fields that are defined in the document's schema. By default, `toObject()` returns all fields in the underlying document from MongoDB, including ones that are not listed in the schema.
4067
4094
* @return {Object} document as a plain old JavaScript object (POJO). This object may contain ObjectIds, Maps, Dates, mongodb.Binary, Buffers, and other non-POJO values.
@@ -4334,6 +4361,7 @@ function omitDeselectedFields(self, json) {
4334
4361
* @param {Object} options
4335
4362
* @param {Boolean} [options.flattenMaps=true] if true, convert Maps to [POJOs](https://masteringjs.io/tutorials/fundamentals/pojo). Useful if you want to `JSON.stringify()` the result.
4336
4363
* @param {Boolean} [options.flattenObjectIds=false] if true, convert any ObjectIds in the result to 24 character hex strings.
4364
+
* @param {Boolean} [options.schemaFieldsOnly=false] - If true, the resulting object will only have fields that are defined in the document's schema. By default, `toJSON()` returns all fields in the underlying document from MongoDB, including ones that are not listed in the schema.
/** if `options.virtuals = true`, you can set `options.aliases = false` to skip applying aliases. This option is a no-op if `options.virtuals = false`. */
212
208
aliases?: boolean;
209
+
/** if true, replace any conventionally populated paths with the original id in the output. Has no affect on virtual populated paths. */
210
+
depopulate?: boolean;
211
+
/** if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`. */
212
+
flattenMaps?: boolean;
213
+
/** if true, convert any ObjectIds in the result to 24 character hex strings. */
214
+
flattenObjectIds?: boolean;
215
+
/** apply all getters (path and virtual getters) */
216
+
getters?: boolean;
213
217
/** remove empty objects (defaults to true) */
214
218
minimize?: boolean;
219
+
/** If true, the resulting object will only have fields that are defined in the document's schema. By default, `toJSON()` returns all fields in the underlying document from MongoDB, including ones that are not listed in the schema. */
220
+
schemaFieldsOnly?: boolean;
215
221
/** if set, mongoose will call this function to allow you to transform the returned object */
216
222
transform?: boolean|((
217
223
doc: THydratedDocumentType,
218
224
ret: Record<string,any>,
219
225
options: ToObjectOptions<THydratedDocumentType>
220
226
)=>any);
221
-
/** if true, replace any conventionally populated paths with the original id in the output. Has no affect on virtual populated paths. */
222
-
depopulate?: boolean;
223
-
/** if false, exclude the version key (`__v` by default) from the output */
224
-
versionKey?: boolean;
225
-
/** if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`. */
226
-
flattenMaps?: boolean;
227
-
/** if true, convert any ObjectIds in the result to 24 character hex strings. */
228
-
flattenObjectIds?: boolean;
229
227
/** If true, omits fields that are excluded in this document's projection. Unless you specified a projection, this will omit any field that has `select: false` in the schema. */
230
228
useProjection?: boolean;
229
+
/** if false, exclude the version key (`__v` by default) from the output */
0 commit comments