MongoDB: usuń unikalne ograniczenie
Próbuję przykładu „Opracuj API RESTful za pomocą Node.js z Express i Mongoose” i natrafiłem na problem ze schematem MongoDB:
POST:
{ title: 'My Awesome T-shirt 2',
description: 'All about the details. Of course it\'s black.',
style: '12345' }
{ [MongoError: E11000 duplicate key error index: ecomm_database.products.$style_1 dup key: { : "12345" }]
name: 'MongoError',
err: 'E11000 duplicate key error index: ecomm_database.products.$style_1 dup key: { : "12345" }',
istnieje unikalne ograniczenie w definicji schematu:
var Product = new Schema({
title: { type: String, required: true },
description: { type: String, required: true },
style: { type: String, unique: true },
modified: { type: Date, default: Date.now } });
jak się tego pozbyć? Gdy usuwam unikatowy: prawda i ponownie uruchom aplikację, schemat nie zostanie zaktualizowany.
W jaki sposób mongodb obsługuje „zmienia” schemat?