MongoDB RangeError:尝试写入缓冲区边界之外 [英] MongoDB RangeError: attempt to write outside buffer bounds

查看:38
本文介绍了MongoDB RangeError:尝试写入缓冲区边界之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一直收到此错误,而是针对特定数组.我正在尝试使用 node.js mongodb 本机驱动程序将 JSON 对象插入到 mongodb 集合中.这个 JSON 对象有几个字符串属性和一个大字符串数组属性.数组可以有数千个字符串项.我的 JSON 看起来像这样

I am not receiving this error all the time but for specifics arrays. I am trying to insert a JSON object into mongodb collection using node.js mongodb native driver. This JSON object has couple of string attributes and a big string array attribute. Array could have thousands of string items. My JSON looks like this

{   
    FileName :"504-2345.txt",
    SIMs :["8931440400012","893144040001","4000130360507",.........]
}

知道 MongoDB 何时抛出 RangeError:尝试写入缓冲区边界之外的内容吗?请推荐

Any idea when MongoDB throws RangeError: attempt to write outside buffer bounds? Please suggest

下面的方法在Mongodb中插入数据

Below method insert the data in Mongodb

 Insert: function (data, type, callback) {

    MongoClient.connect(url, function (err, db) {
        // logger.log("info","Before Inserting documents into "+type +" documents =>"+data.length);

        if (err) {
            logger.log("error", err);
        }

        var collection = db.collection(type);
        // Insert some documents
        collection.insertOne(data, function (err, result) {

            if (err) {
                logger.log("error", " Error for Data while inserting  Error =" + err);
            }
            else {
                db.close();
                if (result.ops) {
                    callback(err, result.ops[0]);
                }
            }


        });


    });
},

推荐答案

文档应该小于 16mb.否则会出现异常.您可以参考此 link 了解更多详细信息.您可以在此处使用 gridFs.

The document should be less than 16mb. Otherwise it get exceptions.You can refer this link for more details. You can use gridFs in here.

这篇关于MongoDB RangeError:尝试写入缓冲区边界之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆