Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38337 > unrolled thread

i want to be write below code in Service API with Jax-rs Restful

Started bysiddareddy.moolam@gmail.com
First post2018-06-05 02:56 -0700
Last post2018-06-05 21:21 -0400
Articles 2 — 2 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  i want to be write below code in Service API with Jax-rs Restful siddareddy.moolam@gmail.com - 2018-06-05 02:56 -0700
    Re: i want to be write below code in Service API with Jax-rs Restful Arne Vajhøj <arne@vajhoej.dk> - 2018-06-05 21:21 -0400

#38337 — i want to be write below code in Service API with Jax-rs Restful

Fromsiddareddy.moolam@gmail.com
Date2018-06-05 02:56 -0700
Subjecti want to be write below code in Service API with Jax-rs Restful
Message-ID<8c24dddd-9932-450c-a26b-6b70885e64a3@googlegroups.com>
   code:

package hellomongo;

import java.util.ArrayList;
import java.util.List;
 
import org.bson.Document;
import org.bson.types.ObjectId;

import com.mongodb.DB;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates;


public class Update {

public static void main(String args[]) {

	MongoClient client = new MongoClient("localhost", 27017);
	MongoDatabase database = client.getDatabase("admin");
	MongoCollection<Document> collection = database
			.getCollection("command");

Object id =  new ObjectId("5b16371c425750918ebf1454");
Document newCmd = new Document("d", 4);
collection.updateOne(Filters.eq("_id", id), Updates.addToSet("cmd", newCmd));






}

}

[toc] | [next] | [standalone]


#38346

FromArne Vajhøj <arne@vajhoej.dk>
Date2018-06-05 21:21 -0400
Message-ID<pf7cut$52b$1@gioia.aioe.org>
In reply to#38337
On 6/5/2018 5:56 AM, siddareddy.moolam@gmail.com wrote:
>     code:

> 	MongoClient client = new MongoClient("localhost", 27017);
> 	MongoDatabase database = client.getDatabase("admin");
> 	MongoCollection<Document> collection = database
> 			.getCollection("command");
> 
> Object id =  new ObjectId("5b16371c425750918ebf1454");
> Document newCmd = new Document("d", 4);
> collection.updateOne(Filters.eq("_id", id), Updates.addToSet("cmd", newCmd));

So you write a JAX-RS service class with a @Path annotation
and an update method with a @Post or @Put annotation.

Arne

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web