我正在尝试将JSON字符串保存到mongoDB,似乎字符串的长度太大,并且出现以下错误消息。
MongoError: WiredTigerIndex::insert: key too large to index, failing 23012
我的架构非常简单,
const metadataSchema = new Schema({
userId: { type: String, unique: false },
metadataJSON: { type: String, unique: false, failIndexKeyTooLong: false }
});
const saveMetadata = async (userId, customMetadata) => {
let metadata = METADATA({
userId: userId,
metadataJSON: JSON.stringify(customMetadata)
});
metadata.save(err => {
if (err)
console.log(
"ERROR - Metadata was not inserted and here is the reason : " + err
);
else console.log("All is good, metadata was inserted");
});
};
关于如何插入此大字符串的任何建议?预先感谢。