-2

This is my rethink document I need a simple query in java to update the menuItemIds list.

{
    "id":  "1a89a4b6-36a3-4378-8ddb-26d0d90f3055" ,
    "menuItemIds": [
        "178de705-59d7-4c5d-8a25-f7e0a226e510" ,
        "sfefe-edwef-wefwefwe-wef"
    ],
    "vendorId":  "e2c1e97d-3996-40c2-9c14-86f824203812"
}
demongolem
  • 9,474
  • 36
  • 90
  • 105
  • initially i created the table by follownig code `Menu menu = new Menu(); menu.setVendorId(menuItem.getVendorId()); List menuItemIDs = new LinkedList<>(); menuItemIDs.add(menuId); menuItemIDs.add("sfefe-edwef-wefwefwe-wef"); menu.setMenuItemIds(menuItemIDs); r.table("menu").insert(menu).run(conn); return new Response("OK","OK");` – Nayeem Ur Rehman Apr 27 '17 at 05:09
  • Welcome to stackoverflow. Please, edit your question for adding aditional information about your problem. Keep the style on it and not post code like a comment. Hard to read... – Kenzo_Gilead Apr 27 '17 at 06:54

1 Answers1

0

Updating a record in rethink works like this: fetch the row you want through get(id) and call update(). Pass the new list through a hashmap.

r.table('tableName').get("1a89a4b6-36a3-4378-8ddb-26d0d90f3055")
.update(r.hashMap("menuItemIds", newMenuList)).run(conn)

You might want to check out the documentation.

DGK
  • 2,947
  • 5
  • 32
  • 47