我们如何解决:" DBCollection类型中的方法insert(DBObject [])不适用于参数(BasicDBObject)?

时间:2016-03-09 12:18:03

标签: java mongodb

我正在使用Mongodb和java并尝试创建文档:

// mongo-java-driver-2.10.1 version
// create a document to store key and value
            BasicDBObject document = new BasicDBObject();
            document.put("name", "Yassine LD");

            BasicDBObject documentDetail = new BasicDBObject();
            documentDetail.put("addressLine1", "Sweet Home");
            documentDetail.put("addressLine2", "New Street");
            documentDetail.put("addressLine3", "CASABLANCA, MOROCCO");

            document.put("address", documentDetail);

            table.insert(document);

我收到此错误:DBCollection类型中的方法insert(DBObject [])不适用于参数(BasicDBObject)

1 个答案:

答案 0 :(得分:1)

您的{ createAction, handleAction, handleActions } = require 'redux-actions'方法似乎需要一个insert数组。假设DBObjectBasicDBObject的子类,您可以写:

DBObject