Updating Edge Property - Embedded Map

Dear Team,
I am storing list of schedules in embedded map as property in Edge type. I need to append the schedule whenever new schedule updated between two vertex, The schedule is for pick up and drop-off of kids. I am using orientjs library to update the schedule.

The update query is below
UPDATE EDGE Picks_From_Home SET SCHEDULE[“01/Apr/2020”,“02/Apr/2020”,“03/Apr/2020”,“06/Apr/2020”,“07/Apr/2020”,“08/Apr/2020”,“09/Apr/2020”,“10/Apr/2020”,“13/Apr/2020”,“14/Apr/2020”,“15/Apr/2020”,“16/Apr/2020”,“17/Apr/2020”,“20/Apr/2020”,“21/Apr/2020”,“22/Apr/2020”,“23/Apr/2020”,“24/Apr/2020”,“27/Apr/2020”,“28/Apr/2020”,“29/Apr/2020”,“30/Apr/2020”] =“7” where @rid IN[#43:23,#44:23].

Problem
I try execute the same query from studio, all are working which was shown below
{
“12/Mar/2020”: “7”,
“18/Mar/2020”: “7”,
“05/Mar/2020”: “7”,
“25/Mar/2020”: “7”,
“31/Mar/2020”: “7”,
“19/Mar/2020”: “7”,
“24/Mar/2020”: “7”,
“06/Mar/2020”: “7”,
“09/Mar/2020”: “7”,
“02/Mar/2020”: “7”,
“30/Mar/2020”: “7”,
“11/Mar/2020”: “7”,
“23/Mar/2020”: “7”,
“04/Mar/2020”: “7”,
“20/Mar/2020”: “7”,
“10/Mar/2020”: “7”,
“16/Mar/2020”: “7”,
“27/Mar/2020”: “7”,
“03/Mar/2020”: “7”,
“17/Mar/2020”: “7”,
“26/Mar/2020”: “7”,
“13/Mar/2020”: “7”,
“01/Apr/2020”: “7”,
“02/Apr/2020”: “7”,
“03/Apr/2020”: “7”,
“06/Apr/2020”: “7”,
“07/Apr/2020”: “7”,
“08/Apr/2020”: “7”,
“09/Apr/2020”: “7”,
“10/Apr/2020”: “7”,
“13/Apr/2020”: “7”,
“14/Apr/2020”: “7”,
“15/Apr/2020”: “7”,
“16/Apr/2020”: “7”,
“17/Apr/2020”: “7”,
“20/Apr/2020”: “7”,
“21/Apr/2020”: “7”,
“22/Apr/2020”: “7”,
“23/Apr/2020”: “7”,
“24/Apr/2020”: “7”,
“27/Apr/2020”: “7”,
“28/Apr/2020”: “7”,
“29/Apr/2020”: “7”,
“30/Apr/2020”: “7”
}

However, When I tried to execute the sam query from orientjs
entries are updated with

{“12/Mar/2020”:“7”,
“18/Mar/2020”:“7”,
“05/Mar/2020”:“7”,
“25/Mar/2020”:“7”,
“31/Mar/2020”:“7”,
“19/Mar/2020”:“7”,
“24/Mar/2020”:“7”,
“06/Mar/2020”:“7”,
“09/Mar/2020”:“7”,
“02/Mar/2020”:“7”,
“30/Mar/2020”:“7”,
“11/Mar/2020”:“7”,
“23/Mar/2020”:“7”,
“04/Mar/2020”:“7”,
“20/Mar/2020”:“7”,
“10/Mar/2020”:“7”,
“16/Mar/2020”:“7”,
“27/Mar/2020”:“7”,
“03/Mar/2020”:“7”,
“17/Mar/2020”:“7”,
“26/Mar/2020”:“7”,
“13/Mar/2020”:“7”,
"[“01/Apr/2020”,“02/Apr/2020”,“03/Apr/2020”,“06/Apr/2020”,“07/Apr/2020”,“08/Apr/2020”,“09/Apr/2020”,“10/Apr/2020”,“13/Apr/2020”,“14/Apr/2020”,“15/Apr/2020”,“16/Apr/2020”,“17/Apr/2020”,“20/Apr/2020”,“21/Apr/2020”,“22/Apr/2020”,“23/Apr/2020”,“24/Apr/2020”,“27/Apr/2020”,“28/Apr/2020”,“29/Apr/2020”,“30/Apr/2020”]
":“7”}

I just looked at the logs in OrientDB by enabling binary protocol logs. It seems no issue with query but not sure additional quotes

Could any one help or come across this issue before

Thanks
Jai

I have further investigated, it seems the query compiler adding additional quotes. Can any one please has come across this weird problem and am not sure what is going on internally. Its bit urgent. could any one hlep

Hi @Jaisundar

which API of OrientJS are you using?

The legacy API
http://orientdb.com/docs/3.0.x/orientjs/OrientJS-Legacy.html

or
the 3.0.x one

http://orientdb.com/docs/3.0.x/orientjs/OrientJS.html

Thanks

I am using http://orientdb.com/docs/3.0.x/orientjs/OrientJS.html

I have also tested with latest version of OrientDB, 3.0.26

No change. Also, I have noticed another problem… trying embedded Map property with new entry start with number throws error but with string no error. Example

SCHEDULE.Apr012020 works fine but SCHEDULE.01Apr2020 does not.

I have opened debug logs in OrientJS , it seems query formation is fine.

Thanks

Jai

1557570722146.png

Hi @Jaisundar

How are you connecting to the db? If you use the legacy API you will end up using the old query parser/executor, which is different from the studio one

Example



const OrientDB = require("orientjs");

const server = OrientDB({
  host: "localhost",
  port: 2424,
  username: "root",
  password: "root_passwd"
});
(async function() {
  const db = server.use({
    username: "admin",
    password: "admin",
    name: "gianni"
  });

  try {
    await db.open();
    let results = await db
      .query(
        `UPDATE Test SET SCHEDULE["01/Apr/2020","02/Apr/2020","03/Apr/2020","06/Apr/2020","07/Apr/2020","08/Apr/2020","09/Apr/2020","10/Apr/2020","13/Apr/2020","14/Apr/2020","15/Apr/2020","16/Apr/2020","17/Apr/2020","20/Apr/2020","21/Apr/2020","22/Apr/2020","23/Apr/2020","24/Apr/2020","27/Apr/2020","28/Apr/2020","29/Apr/2020","30/Apr/2020"] ="7"`
      )
      .all();

    console.log(JSON.stringify(results));
  } catch (e) {
    console.log(e);
  }
})();

I’ve tried this and had the same problem. You should switch to the new API 3.0.x which uses the new parser/executors with the new protocol of OrientDB 3.0.x

Example


const OrientDBClient = require("orientjs").OrientDBClient;

(async function() {
  let client = await OrientDBClient.connect({ host: "localhost", port: 2424 });

  let session = await client.session({
    name: "gianni",
    username: "admin",
    password: "admin"
  });

  try {
    let results = await session
      .command(
        `UPDATE Test SET SCHEDULE["01/Apr/2020","02/Apr/2020","03/Apr/2020","06/Apr/2020","07/Apr/2020","08/Apr/2020","09/Apr/2020","10/Apr/2020","13/Apr/2020","14/Apr/2020","15/Apr/2020","16/Apr/2020","17/Apr/2020","20/Apr/2020","21/Apr/2020","22/Apr/2020","23/Apr/2020","24/Apr/2020","27/Apr/2020","28/Apr/2020","29/Apr/2020","30/Apr/2020"] ="7"`
      )
      .all();

    console.log(JSON.stringify(results));
  } catch (e) {
    console.log(e);
  }
})();

This works fine. Let me know if this helps

Thanks

Thanks, I will try and update you. However, would like to understand about the parser. When you say the parser, does it point to OrientJS or dB server. Also could you please point me the new protocol class in dB server.

Thanks

Jai

1557570722146.png

Hi @Jaisundar

the new API in OrientJS uses the new OrientDB parser/executor in 3.0.x, which is more stable and provide new functionality. It’s part of OrientDB 3.0.x release. We couldn’t upgrade directly the old OrientJS API without breaking the compatibility. So for a better OrientDB 3.0.x support you should switch to the new API of OrientJS with OrientDBClient.

Thanks and will let you know my progress…

Thanks

Jai

1557570722146.png