/** * Inserts objects into the database. * if the objects _id is null, one will be generated * you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result * * @param list The objects to insert * @return The result * @throws MongoException If an error occurred */ @SuppressWarnings({"unchecked"}) public WriteResult<T, K> insert(List<T> list) throws MongoException { return insert(list.toArray((T[]) new Object[list.size()])); }
/** * Inserts objects into the database. * if the objects _id is null, one will be generated * you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result * * @param list The objects to insert * @param concern the write concern * @return The result * @throws MongoException If an error occurred */ @SuppressWarnings({"unchecked"}) public WriteResult<T, K> insert(List<T> list, WriteConcern concern) throws MongoException { return insert(concern, list.toArray((T[]) new Object[list.size()])); }
/** * Inserts objects into the database. * if the objects _id is null, one will be generated * you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result * * @param list The objects to insert * @param concern the write concern * @return The result * @throws MongoException If an error occurred */ @SuppressWarnings({"unchecked"}) public WriteResult<T, K> insert(List<T> list, WriteConcern concern) throws MongoException { return insert(concern, list.toArray((T[]) new Object[list.size()])); }
/** * Inserts objects into the database. * if the objects _id is null, one will be generated * you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result * * @param list The objects to insert * @return The result * @throws MongoException If an error occurred */ @SuppressWarnings({"unchecked"}) public WriteResult<T, K> insert(List<T> list) throws MongoException { return insert(list.toArray((T[]) new Object[list.size()])); }
@POST @Timed public Response publishNewBlog(@Valid Blog blog) { collection.insert(blog); return Response.noContent().build(); } }
@Path("bar") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Bar addBar(Bar bar) { WriteResult<Bar, String> result = getJacksonDBCollection().insert(bar); return result.getSavedObject(); }