ごめんなさい。元の内容嘘でした。直接defaultに設定できます。
var schema = new Schema({
mycolumn: {
type: [String],
default: ["DefaultString1", "DefaultString2"]
}
});
もしも一個だったら配列にしないでおいても融通きかせて配列にしてくれます
var schema = new Schema({
mycolumn: {
type: [String],
default: "DefaultString1"
}
});
以下の内容は嘘です。
https://groups.google.com/forum/#!topic/mongoose-orm/W-fVEyx3O9A
から
https://gist.github.com/aheckmann/3801422
へ誘導されて
var schema = new Schema({
name: String
, docs: { type: [docs], default: function () {
// need to manaually add the ObjectId in this case
return [{ name: 20, _id: new mongoose.Types.ObjectId }]
}}
});
ようするに、defaultに関数を設定できるということだそうだ。
var schema = new Schema({
mycolumn: {
type: [String],
default: function () {
return ["DefaultString1", "DefaultString2"];
}
}
});