0
回答
想在单元测试中用mongoose一次插入多条记录为什么只插入了部分记录
科大讯飞通用文字识别100000次/天免费使用。立即申请   
    var testMdl = Mongoose.model("testSechma", testSechma);
        var docs = [];
        for (var i = 0; i < 100; i++) {
            var doc = {};
            doc.col_name = "T" + i.toString();
            doc.col_value = [];
            for (var j = 0; j < Math.random() * 10; j++) {
                doc.col_value.push((new Date().getDate() - Math.floor(Math.random() * 100)).toLocaleString());
            }
            docs.push(doc);
        }
        //var promise = testMdl.create(docs);
        promise = testMdl.create([
            { col_name: "A", col_value: ["S1"] },
            { col_name: "F", col_value: ["Q1"] },
            { col_name: "B", col_value: ["R1"] },
            { col_name: "C", col_value: ["W1"] },
            { col_name: "D", col_value: ["F1"] },
            { col_name: "E", col_value: ["E1"] },
        ]);
        promise.then(function (docs) {
            console.info("docs:", docs);
        }).catch(function (reason) {
            console.error("reason:", reason);
        });

IDE是VS2015,做的单元测试里想一次插入多条记录,但是一次只插入了4条记录。请问是什么原因呢?


举报
faete
发帖于2年前 0回/267阅
顶部