0
でそれを拾うされていません。マングースのスキーマの更新は、私は、次のスキーマ持っているところ、私は私のDBは、既に作成したのMongoDBデータベース
const ProjectSchema = new mongoose.Schema({
name: { type: String },
description: { type: String },
client: {
type: mongoose.Schema.Types.ObjectId,
ref: 'client'
},
group: {
type: mongoose.Schema.Types.ObjectId,
ref: 'project_group'
}
});
を私は
const ProjectSchema = new mongoose.Schema({
name: { type: String, unique: true, required: true },
description: { type: String },
client: {
type: mongoose.Schema.Types.ObjectId,
ref: 'client'
},
group: {
type: mongoose.Schema.Types.ObjectId,
ref: 'project_group'
}
});
にスキーマを変更する必要があるため、私たちは名前がnullではなく一意であることを強制する必要があります。この定義を変更した後、私はdbが同じ名前の値を持つ文書を保存していることがわかります。私の質問は、スキーマで行った変更をどのように適用できますか?これを手動で実行せずに自動的に行うにはどうすればよいですか?
安心して
ありがとうございます。それが私が探しているものです。 – user3005919