Re: REST API on top of ignite using node express

2020-02-14 Thread Ilya Kasnacheev
Hello!

* I have just tried modifying this example:
https://github.com/apache/ignite/blob/master/modules/platforms/nodejs/examples/SqlExample.js
and it was able to list all 4000+ cities from City table with no problems
(mind the SQL file in examples directory shipped with Ignite). What version
are you using? Can you provide complete reproducer together with data?

* To get field names in cursor, you first have to do
query.setIncludeFieldNames(true). By default you are not getting them.

Regards,
-- 
Ilya Kasnacheev


пн, 10 февр. 2020 г. в 22:59, nithin91 <
nithinbharadwaj.govindar...@franklintempleton.com>:

> Hi ,
>
> We are trying to build an Rest API on top of ignite cache using node
> express.
>
> Following is the way we are fetching data from ignite.
>
> await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
> const cache = igniteClient.getCache(CacheNAME);
>
> const querysql=new SqlFieldsQuery("SqL");
> const cursor = await cache.query(querysql);
> const row =await  cursorProductDetails.getValue();
>
> We are facing the following issues while fetching the data in cursor.
>
> 1. cursor._values property is always having only 1024 rows even though the
> table as 100k rows.
> 2. cursor._fieldnames  property  is not displaying the field names as
> result
> of which we have created an
> array with list of fields and creating a list of json objects using this
> array and  traversing each row of cursor._values using map function.
>
> Please check below for sample code
>
> var dataProductDetails=cursor._values ;
>
> var res_data_prddetails=[];
>
>  var fields=[field1,field2]
>
> await dataProductDetails.map(function(arr){
>  var prdobj={};
>  fields.forEach((k,v)=> prdobj[k]=arr[v]);
>  res_data_prddetails.push(prdobj);
>}
>
>
>   );
>
> Also can you please let me know whether there is a way to directly convert
> the sql fields query output to JSON using node express.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


Re: REST API on top of ignite using node express

2020-02-13 Thread Denis Magda
Hi Nithin,

1. You can use Query.setPageSize method to instruct the Cursor to read the
result set in chunks bigger than 1024. However, regardless of the pageSize
the Cursor returns the whole result:
https://github.com/apache/ignite/blob/master/modules/platforms/nodejs/lib/Query.js#L56

2. That's how cursor._fieldnames are implemented:
https://github.com/apache/ignite/blob/master/modules/platforms/nodejs/lib/Cursor.js#L264

-
Denis


On Mon, Feb 10, 2020 at 11:59 AM nithin91 <
nithinbharadwaj.govindar...@franklintempleton.com> wrote:

> Hi ,
>
> We are trying to build an Rest API on top of ignite cache using node
> express.
>
> Following is the way we are fetching data from ignite.
>
> await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
> const cache = igniteClient.getCache(CacheNAME);
>
> const querysql=new SqlFieldsQuery("SqL");
> const cursor = await cache.query(querysql);
> const row =await  cursorProductDetails.getValue();
>
> We are facing the following issues while fetching the data in cursor.
>
> 1. cursor._values property is always having only 1024 rows even though the
> table as 100k rows.
> 2. cursor._fieldnames  property  is not displaying the field names as
> result
> of which we have created an
> array with list of fields and creating a list of json objects using this
> array and  traversing each row of cursor._values using map function.
>
> Please check below for sample code
>
> var dataProductDetails=cursor._values ;
>
> var res_data_prddetails=[];
>
>  var fields=[field1,field2]
>
> await dataProductDetails.map(function(arr){
>  var prdobj={};
>  fields.forEach((k,v)=> prdobj[k]=arr[v]);
>  res_data_prddetails.push(prdobj);
>}
>
>
>   );
>
> Also can you please let me know whether there is a way to directly convert
> the sql fields query output to JSON using node express.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


REST API on top of ignite using node express

2020-02-10 Thread nithin91
Hi ,

We are trying to build an Rest API on top of ignite cache using node
express.

Following is the way we are fetching data from ignite.

await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
const cache = igniteClient.getCache(CacheNAME);

const querysql=new SqlFieldsQuery("SqL");
const cursor = await cache.query(querysql);
const row =await  cursorProductDetails.getValue();

We are facing the following issues while fetching the data in cursor.

1. cursor._values property is always having only 1024 rows even though the
table as 100k rows.
2. cursor._fieldnames  property  is not displaying the field names as result
of which we have created an 
array with list of fields and creating a list of json objects using this
array and  traversing each row of cursor._values using map function.

Please check below for sample code

var dataProductDetails=cursor._values ;

var res_data_prddetails=[];

 var fields=[field1,field2]

await dataProductDetails.map(function(arr){
 var prdobj={};
 fields.forEach((k,v)=> prdobj[k]=arr[v]);
 res_data_prddetails.push(prdobj);
   }

   
  );

Also can you please let me know whether there is a way to directly convert
the sql fields query output to JSON using node express.

















--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


REST API on top of ignite using node express

2020-02-10 Thread nithin91
Hi ,

We are trying to build an Rest API on top of ignite cache using node
express.

Following is the way we are fetching data from ignite.

await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
const cache = igniteClient.getCache(CacheNAME);

const querysql=new SqlFieldsQuery("SqL");
const cursor = await cache.query(querysql);
const row =await  cursorProductDetails.getValue();

We are facing the following issues while fetching the data in cursor.

1. cursor._values property is always having only 1024 rows even though the
table as 100k rows.
2. cursor._fieldnames  property  is not displaying the field names as result
of which we have created an 
array with list of fields and creating a list of json objects using this
array and  traversing each row of cursor._values using map function.

Please check below for sample code

var dataProductDetails=cursor._values ;

var res_data_prddetails=[];

 var fields=[field1,field2]

await dataProductDetails.map(function(arr){
 var prdobj={};
 fields.forEach((k,v)=> prdobj[k]=arr[v]);
 res_data_prddetails.push(prdobj);
   }

   
  );

Also can you please let me know whether there is a way to directly convert
the sql fields query output to JSON using node express.

















--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


REST API on top of ignite using node express

2020-02-10 Thread nithin91
Hi ,

We are trying to build an Rest API on top of ignite cache using node
express.

Following is the way we are fetching data from ignite.

await igniteClient.connect(new IgniteClientConfiguration(ENDPOINT));
const cache = igniteClient.getCache(CacheNAME);

const querysql=new SqlFieldsQuery("SqL");
const cursor = await cache.query(querysql);
const row =await  cursorProductDetails.getValue();

We are facing the following issues while fetching the data in cursor.

1. cursor._values property is always having only 1024 rows even though the
table as 100k rows.
2. cursor._fieldnames  property  is not displaying the field names as result
of which we have created an 
array with list of fields and creating a list of json objects using this
array and  traversing each row of cursor._values using map function.

Please check below for sample code

var dataProductDetails=cursor._values ;

var res_data_prddetails=[];

 var fields=[field1,field2]

await dataProductDetails.map(function(arr){
 var prdobj={};
 fields.forEach((k,v)=> prdobj[k]=arr[v]);
 res_data_prddetails.push(prdobj);
   }

   
  );

Also can you please let me know whether there is a way to directly convert
the sql fields query output to JSON using node express.

















--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/