Example usage for com.mongodb DBCollection insert

List of usage examples for com.mongodb DBCollection insert

Introduction

In this page you can find the example usage for com.mongodb DBCollection insert.

Prototype

public WriteResult insert(final List<? extends DBObject> documents, final InsertOptions insertOptions) 

Source Link

Document

Insert documents into a collection.

Usage

From source file:rtpmt.models.Temperature.java

public void save() {
    DBCollection packageColl = db.getCollection(DBConstants.TEMPERATURE_COLLECTION);
    /*//from   w w w  .ja  va2 s.  com
    BasicDBObject query = new BasicDBObject();
    query.put(DBConstants.SENSOR_ID, this.get(DBConstants.SENSOR_ID));
    query.put(DBConstants.TRUCK_ID, this.get(DBConstants.TRUCK_ID));
    query.put(DBConstants.PACKAGE_ID,this.get(DBConstants.PACKAGE_ID));
    query.put(DBConstants.TIMESTAMP, this.get(DBConstants.TIMESTAMP));
    BasicDBObject set = new BasicDBObject();
    set.put("$set", this);
            
    packageColl.update(query, set, true, false);
        */
    packageColl.insert(this, WriteConcern.ACKNOWLEDGED);
}