Support for "[{}]" structure
Closed this issue · 1 comments
mounan commented
Sorry, is the customize mode supporting the "[{}]" structure?
For example, how can I skip the updated
field below?
information: [{
updated: { type: Date, default: Date.now },
title: String,
content: String,
}],
faboulaws commented
You can with the options below
const options = {
information: {
updated: {
skip: true
}
}
};
Full example
const mongoose = require('mongoose');
const {factory} = require('fakingoose');
const {
Schema
} = mongoose;
const schema = new Schema({
information: [{
updated: { type: Date, default: Date.now },
title: String,
content: String,
}]
});
const options = {
information: {
updated: {
skip: true
}
}
};
const myFactory = factory(schema, options);
const mock = myFactory.generate();
Sample data
{
"information": [
{
"title": "&2jnow8tpfk1w",
"content": "zj2@(44^ro1@",
"_id": "60f14acfecffa30001159bdf"
},
{
"title": "xnzry!(e38!t]",
"content": "(baheaov$",
"_id": "60f14acfecffa30001159be0"
}
],
"_id": "60f14acfecffa30001159be1"
}