Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cursor.getFieldNames is not returning the Field name in SqlExample.js shipped with Ignite #2

Open
nithin91-govind opened this issue Feb 13, 2020 · 0 comments

Comments

@nithin91-govind
Copy link

Hi ,

In the SqlExample.js shipped with Ignite, the output of this method is not returning the field names.

const fieldNames = cursor.getFieldNames();

Actually 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 data=await cursorProductDetails.getAll();

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

  1. 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

const querysql=new SqlFieldsQuery("SqL");
const dataProductDetails= (await cache.query(querysql)).getAll();

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant