0
votes

I am new to Apache Ignite.Can someone help me on how to fetch and load the data from ignite cache using node js without using sql field queries option. Cache is loaded using CacheJDBCPOJO Store and the Key and Value types are custom types defined using JAVA.As these classes are defined in Java not sure on how to fetch the data using node.

Hope the following example , explains the issue better.

We have ignite cache of custom key Type i.e Person Key with attributes Person First Name and person Last Name and custom value type i.e Person Info with attributes Person Address and Person Age etc. These classes are defined in Java and the caches are configured in Bean File and loaded using CacheJDBCPOJO Store.

As these classes will not be available in node js, how can we load /fetch the data from node js using cahe.put /cache.get.Tried creating similar classes in node and pass the object of these classes to cahe.put /cache.get but it is in't working.

1
"but it is in't working" - what's the error? - alamar
Hi Pasted below error i got.Actually i am trying query an existing cache using node js which is loaded via Cache JDBC Pojo Store in Java.It would be really helpful if you share me any sample code. ERROR: Binary type has different field types [typeName=OrderId, fieldName=OrderID, fieldTypeName1=long, fieldTypeName2=double] (node:13596) UnhandledPromiseRejectionWarning: ReferenceError: igniteClient is not defined at start (C:\Users\ngovind\NodeApp\NodeIgnite.js:44:5) at processTicksAndRejections (internal/process/task_queues.js:93:5) - Nithin Govindaraju
Also We are trying to build an Rest API on top of ignite cache using node express. Can you please let me know whether there is a way to directly convert the sql fields query output to JSON using node express. - Nithin Govindaraju
Thanks for the answer.It is really Helpful.Can't we convert an SQL Fields Query Output to JSON using node js.? - Nithin Govindaraju
Are we talking about REST or node.js? Both have SQL support. - alamar

1 Answers

0
votes

I can see the following error:

ERROR: Binary type has different field types [typeName=OrderId, fieldName=OrderID, fieldTypeName1=long, fieldTypeName2=double] (node:13596)

Which will probably be fixed by removing ignite work dir (/tmp/ignite/work or ./ignite/work by default) and restarting all your nodes, and as such, not related directly to node.js

As for examples, have you tried the following: https://apacheignite.readme.io/docs/nodejs-thin-client-binary-types

As for REST API, it should convert BinaryObject's to JSON by default, this should include all SQL columns' values.

Update: Turns out you have to do query.setIncludeFieldNames(true) to make getFieldNames() return field names.