I have this error in my ExpressJS app:
Error updating stream: MongoError: Resulting document after update is larger than 16777216
_http_server.js:192
throw new RangeError(`Invalid status code: ${statusCode}`);
So I assume that my document has exceeded the limit.
How can I increase the limit?
I got this link from this answer. But how do I use it in my app? How do I start?
I am using mongoose to store and retrieve my data.
Any ideas/ hints?
This is my document schema in mongoose:
var mongoose = require("mongoose");
var mongoosePaginate = require('mongoose-paginate');
// Declare schema
var streadatamSchema = new mongoose.Schema({
user_id: {
type: String,
required: true
},
title: {
type: String,
required: true
},
description: {
type: String,
required: true
},
data: {
type: Object
},
entries_number: {
type: Number,
default: 0
},
last_entry_at: {
type: Date
},
created_at: {
type: Date,
default: Date.now,
index: 1 // Note 1
},
});
streamSchema.plugin(mongoosePaginate);
// Export schema
// Model.paginate()
mongoose.model("Stream", streamSchema);
I reckon it is the data
field has too much data in it now.
So I assume that my document has exceeded the limit.
How can I increase the limit?
The size limit in Mongo is hardcoded in the source code:
/* Note the limit here is rather arbitrary and is simply a standard. generally the code works
with any object that fits in ram.
Also note that the server has some basic checks to enforce this limit but those checks are not exhaustive
for example need to check for size too big after
update $push (append) operation
various db.eval() type operations
*/
const int BSONObjMaxUserSize = 16 * 1024 * 1024;
/*
Sometimes we need objects slightly larger - an object in the replication local.oplog
is slightly larger than a user object for example.
*/
const int BSONObjMaxInternalSize = BSONObjMaxUserSize + ( 16 * 1024 );
const int BufferMaxSize = 64 * 1024 * 1024;
The only way to change it is by changing the source code and building your own version of Mongo from the source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With