I am attempting to save a JSON string to mongoDB, it seems that the length of the string is too great and I get the following error message.
MongoError: WiredTigerIndex::insert: key too large to index, failing 23012
My schema is fairly simple,
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");
});
};
Any suggestions on how I could insert this large string? Thanks in advance.