How to generate query with multiple or condtions in sequelize - mysql

I want to query with multiple or conditions in sequelize. Out of two, I have defined only one is reflected in the query generated using sequelize
Current Output:
SELECT `id`, `from_id`, `to_id`, `message`, `format`, `from_type`, `to_type`, `from_deleted_id`, `to_deleted_id`, `created_at`, `updated_at` FROM `messages` AS `Message` WHERE ((`Message`.`from_id` = '1' AND `Message`.`from_type` = 'user') OR
(`Message`.`from_id` = '3' AND `Message`.`from_type` = 'user'))
Expected Output:
SELECT `id`, `from_id`, `to_id`, `message`, `format`, `from_type`, `to_type`, `from_deleted_id`, `to_deleted_id`, `created_at`, `updated_at` FROM `messages` AS `Message` WHERE ((`Message`.`from_id` = '1' AND `Message`.`from_type` = 'user') OR
(`Message`.`from_id` = '3' AND `Message`.`from_type` = 'user')) AND ((`Message`.`to_id` = '1' AND `Message`.`to_type` = 'user') OR
(`Message`.`to_id` = '3' AND `Message`.`to_type` = 'user'))
where object -
where_condition={
[Op.or]: [
{from_id: from_id,from_type:from_type},
{from_id: to_id,from_type:to_type},
],
[Op.or]: [
{to_id: from_id,to_type:from_type},
{to_id: to_id,to_type:to_type},
],
}
Sequlize statement -
models.Message.findAll({where:where_condition})

Where object for having multiple or conditions must be as follow -
where_condition={
[Op.or]: [
{
[Op.and]: [
{
[Op.and]: [{ from_id: from_id }, { from_type: from_type }]
},
{
[Op.and]: [{ from_id: to_id }, { from_type: to_type }]
}
]
},
{
[Op.and]: [
{
[Op.and]: [{ to_id: from_id }, { to_type: from_type }]
},
{
[Op.and]: [{ to_id: to_id }, { to_type: to_type }]
}
]
}
]
}
Hope it helps!

Related

Fetch all records from table A where id = somvalue in B plus records which don't have id in B

I have two tables a coupons table and a coupon_city_map table.
id
coupon_code
1
OFFER20
2
OFFER10
3
OFFER50
4
OFFER40
5
OFFER90
coupon_Id
city_id
1
2
2
3
3
4
4
2
I need coupons with ids 1 4, and 5 for city_id = 2.
So It should fetch all the coupons where city_id=2 i.e. coupons with id 1 and 4
and it should also fetch coupons which don't have key in coupon_city_map i.e 5.
This is what I have tried but the query in [Op.or] is not working, and it returns all the coupons instead.
let coupons = await Coupon.findAll({
where: {
[Op.or]: [
{ '$CouponCities.city_id$': city_id },
{ '$CouponCities.coupon_id$': null },
],
...filters // other filter like is_active: true
},
include: {
model: CouponCity,
attributes: [],
},
attributes: ['id', 'coupon_code', 'discount_per', 'flat_discount', 'discount_upto', 'description', 'display'],
});
The query being generated
SELECT `Coupon`.`id`,
`Coupon`.`coupon_code`,
`Coupon`.`discount_per`,
`Coupon`.`flat_discount`,
`Coupon`.`discount_upto`,
`Coupon`.`description`,
`Coupon`.`display`
FROM `coupons` AS `Coupon`
LEFT OUTER JOIN `coupon_city_map` AS `CouponCities` ON `Coupon`.`id` = `CouponCities`.`coupon_id`
WHERE (`Coupon`.`user_id` IS NULL OR `Coupon`.`user_id` = 1)
AND `Coupon`.`is_active` = true
AND `Coupon`.`is_external` = false
AND `Coupon`.`start_date` < '2020-12-30 10:33:20'
AND `Coupon`.`expiry_date` > '2020-12-30 10:33:20';
Update
I also tried below, but still it is returning all the coupons.
let coupons = await Coupon.findAll({
// where: {
// ...filters,
// },
include: {
model: CouponCity,
required: false,
where: {
[Op.or]: [
{
zone_id: zoneId,
}, {
coupon_id: null,
},
],
},
attributes: [],
},
attributes: ['id', 'coupon_code', 'discount_per', 'flat_discount','discount_upto', 'description', 'display'],
});
...and it generates below query.
SELECT `Coupon`.`id`,
`Coupon`.`coupon_code`,
`Coupon`.`discount_per`,
`Coupon`.`flat_discount`,
`Coupon`.`discount_upto`,
`Coupon`.`description`,
`Coupon`.`display`
FROM `coupons` AS `Coupon`
LEFT OUTER JOIN `coupon_city_map` AS `CouponCities`
ON `Coupon`.`id` = `CouponCities`.`coupon_id`
AND ( `CouponCities`.`zone_id` = 1
AND `CouponCities`.`coupon_id` IS NULL )
WHERE `Coupon`.`is_active` = true
AND `Coupon`.`is_external` = false;
This is what worked for me, query is mess but it works. I am posting all the codes for better understanding for anyone interested.
Here zone is city.
{
const filters = {
start_date: {
[Op.lt]: new Date(),
},
expiry_date: {
[Op.gt]: new Date(),
},
};
if (userId) {
filters[Op.or] = [{
user_id: null,
}, {
user_id: userId,
}];
filters[Op.and] = {
[Op.or]: [
sequelize.literal('CouponZones.zone_id = 1'),
sequelize.literal('CouponZones.coupon_id IS null')
],
};
} else {
filters.user_id = null;
}
let coupons = await Coupon.findAll({
where: {
...filters,
},
include: {
model: CouponZone,
attributes: [],
},
attributes: ['id', 'coupon_code', 'discount_per', 'flat_discount', 'discount_upto', 'description', 'display'],
});
This is the query it generates.
SELECT `Coupon`.`id`,
`Coupon`.`coupon_code`,
`Coupon`.`discount_per`,
`Coupon`.`flat_discount`,
`Coupon`.`discount_upto`,
`Coupon`.`description`,
`Coupon`.`display`
FROM `coupons` AS `Coupon`
LEFT OUTER JOIN `coupon_zone_map` AS `CouponZones`
ON `Coupon`.`id` = `CouponZones`.`coupon_id`
WHERE ( `Coupon`.`user_id` IS NULL
OR `Coupon`.`user_id` = 1 )
AND ((CouponZones.zone_id = 1 OR CouponZones.coupon_id IS null))
AND `Coupon`.`is_active` = true
AND `Coupon`.`is_external` = false;
Use UNION
You can write query like below
SELECT coupons.*
FROM coupons,
coupon_city_map
WHERE coupons.id = coupon_city_map.coupon_id
AND coupon_city_map.city_id = 2
UNION
SELECT coupons.*
FROM coupons
WHERE coupons.id NOT IN(SELECT coupon_city_map.coupon_id
FROM coupon_city_map)

How to select field from a sibling array?

I would like to select value ('Value') from element with FieldName=Field4 where value ('Value') is null from element with FieldName=Field2.
{
"FormName":"Form1",
"Id": "ID1",
"Module":{
"ModuleType":"Form",
"Layout":"Vertical",
"ControlList":[
{
"ControlType":"Widget",
"Layout":"Vertical",
"FieldList":[
{
"FieldType":"TextBox",
"FieldName":"Field1",
"Value":"field1"
},
{
"FieldType":"TextBox",
"FieldName":"Field2",
"Value":null
},
{
"FieldType":"TextBox",
"FieldName":"Field1",
"Value":"field3"
}
]
},
{
"ControlType":"Widget",
"Layout":"Vertical",
"FieldList":[
{
"row":[
{
"FieldType":"TextBox",
"FieldName":"Field3",
"Value":"field3"
},
{
"FieldType":"TextBox",
"FieldName":"Field4",
"Value":"field4"
}
]
}
]
}
]
}
}
I understand how to get the right dataset:
select
form.Id
from
`test` as form
where
any cl in form.Module.ControlList satisfies
any fl in cl.FieldList satisfies fl.FieldName = 'Field2' AND fl.`Value` is null
end
end;
... returning:
[
{
"Id": "ID1"
}
]
But how should my select statement look like to get this:
[
{
"Value": "field4"
}
]
Use ARRAY construct
SELECT
ARRAY_FLATTEN((ARRAY (ARRAY (ARRAY {r.`Value`}
FOR r IN f.`row`
WHEN r.FieldName = "Field4"
END)
FOR f IN c.FieldList
END)
FOR c IN t.Module.ControlList
END),3)[0].*
FROM `test` AS t
WHERE (ANY cl IN t.Module.ControlList
SATISFIES (ANY fl IN cl.FieldList
SATISFIES fl.FieldName = 'Field2' AND fl.`Value` IS NULL
END)
END);

Indexes for couchbase query

Could you please suggest possible couchbase indexes for this query and how you drive your choices?
SELECT Count(*) AS count
FROM `ORDER`
WHERE `_class` = "com.lbk.entities.OrderEntity"
AND (
lower(buyer.contact.firstname) LIKE '%aziz%'
OR lower(buyer.contact.lastname) LIKE '%aziz%'
OR ANY communicationchannel IN buyer.contact.communicationchannel satisfies ( communicationchannel.communicationchannelcode = 'EMAIL'
AND communicationchannel.communicationvalue = NULL )
END )
AND ordertypecode = '220'
AND (
ordercategory != 'EXCLUDED_CAT'
OR ordercategory IS NOT valued )
AND creationdatetime IN
(
SELECT raw max(o2.creationdatetime)
FROM `ORDER` o2
WHERE (
lower(o2.buyer.contact.firstname) LIKE '%aziz%'
OR lower(o2.buyer.contact.lastname) LIKE '%aziz%'
OR ANY communicationchannel IN o2.buyer.contact.communicationchannel satisfies ( communicationchannel.communicationchannelcode = 'EMAIL'
AND communicationchannel.communicationvalue = NULL )
END )
AND ANY communicationchannel IN o2.buyer.contact.communicationchannel satisfies ( communicationchannel.communicationchannelcode = 'EMAIL'
AND communicationchannel.communicationvalue IS NOT NULL ) END
AND o2.ordertypecode = '220'
AND (
o2.ordercategory != 'EXCLUDED_CAT'
OR o2.ordercategory IS NOT valued)
GROUP BY ( array item.communicationvalue FOR item IN o2.buyer.contact.communicationchannel WHEN item.communicationchannelcode = 'EMAIL'
END )
)
i have created this index which is hitted by the query :
CREATE INDEX `idx_customer` ON
`order`(`_class`, ((`buyer`.`contact`).`firstname`), ((`buyer`.`contact`).`lastname`), (DISTINCT (array
(`aoc`.`communicationvalue`) FOR `aoc` IN ((`buyer`.`contact`).`communicationchannel`) WHEN
((`aoc`.`communicationchannelcode`) = "EMAIL") end)))
but my performances are poor and corresponding to other responses it is mainely due to my poor index design.
the explanition of my query is :
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "UnionScan",
"scans": [
{
"#operator": "IntersectScan",
"scans": [
{
"#operator": "IndexScan3",
"index": "idx_customer1",
"index_id": "d1463e49b12fcd45",
"index_projection": {
"primary_key": true
},
"keyspace": "order",
"namespace": "default",
"spans": [
{
"range": [
{
"high": "\"220\"",
"inclusion": 3,
"low": "\"220\""
},
{
"inclusion": 0,
"low": "null"
}
]
}
],
"using": "gsi"
},
{
"#operator": "DistinctScan",
"scan": {
"#operator": "IndexScan3",
"index": "idx_customer",
"index_id": "2132a2f8632e76f3",
"index_projection": {
"primary_key": true
},
"keyspace": "order",
"namespace": "default",
"spans": [
{
"range": [
{
"high": "\"com.lbk.entities.OrderEntity\"",
"inclusion": 3,
"low": "\"com.lbk.entities.OrderEntity\""
},
{
"inclusion": 0,
"low": "null"
}
]
}
],
"using": "gsi"
}
}
]
},
{
"#operator": "IndexScan3",
"index": "idx_customer1",
"index_id": "d1463e49b12fcd45",
"index_projection": {
"primary_key": true
},
"keyspace": "order",
"namespace": "default",
"spans": [
{
"range": [
{
"high": "\"220\"",
"inclusion": 3,
"low": "\"220\""
},
{
"inclusion": 0,
"low": "null"
}
]
}
],
"using": "gsi"
}
]
},
{
"#operator": "Fetch",
"keyspace": "order",
"namespace": "default"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "((((((`order`.`_class`) = \"com.lbk.entities.OrderEntity\") and (((lower((((`order`.`buyer`).`contact`).`firstName`)) like \"%aziz%\") or (lower((((`order`.`buyer`).`contact`).`lastName`)) like \"%aziz%\")) or any `communicationChannel` in (((`order`.`buyer`).`contact`).`communicationChannel`) satisfies (((`communicationChannel`.`communicationChannelCode`) = \"EMAIL\") and ((`communicationChannel`.`communicationValue`) = null)) end)) and ((`order`.`orderTypeCode`) = \"220\")) and ((not ((`order`.`orderCategory`) = \"EXCLUDED_CAT\")) or ((`order`.`orderCategory`) is not valued))) and ((`order`.`creationDateTime`) in (select raw max((`O2`.`creationDateTime`)) from `order` as `O2` where ((((((lower((((`O2`.`buyer`).`contact`).`firstName`)) like \"%aziz%\") or (lower((((`O2`.`buyer`).`contact`).`lastName`)) like \"%aziz%\")) or any `communicationChannel` in (((`O2`.`buyer`).`contact`).`communicationChannel`) satisfies (((`communicationChannel`.`communicationChannelCode`) = \"EMAIL\") and ((`communicationChannel`.`communicationValue`) = null)) end) and any `communicationChannel` in (((`O2`.`buyer`).`contact`).`communicationChannel`) satisfies (((`communicationChannel`.`communicationChannelCode`) = \"EMAIL\") and ((`communicationChannel`.`communicationValue`) is not null)) end) and ((`O2`.`orderTypeCode`) = \"220\")) and ((not ((`O2`.`orderCategory`) = \"EXCLUDED_CAT\")) or ((`O2`.`orderCategory`) is not valued))) group by array (`item`.`communicationValue`) for `item` in (((`O2`.`buyer`).`contact`).`communicationChannel`) when ((`item`.`communicationChannelCode`) = \"EMAIL\") end)))"
},
{
"#operator": "InitialGroup",
"aggregates": [
"count(*)"
],
"group_keys": []
}
]
}
},
{
"#operator": "IntermediateGroup",
"aggregates": [
"count(*)"
],
"group_keys": []
},
{
"#operator": "FinalGroup",
"aggregates": [
"count(*)"
],
"group_keys": []
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "InitialProject",
"result_terms": [
{
"as": "count",
"expr": "count(*)"
}
]
},
{
"#operator": "FinalProject"
}
]
}
}
]
},
"text": "SELECT COUNT(*) AS count FROM `order` \nWHERE `_class` = \"com.lbk.entities.OrderEntity\" \nAND ( \nLOWER(buyer.contact.firstName) LIKE '%aziz%' OR LOWER(buyer.contact.lastName) LIKE '%aziz%' \nOR ANY communicationChannel IN buyer.contact.communicationChannel SATISFIES ( communicationChannel.communicationChannelCode = 'EMAIL' AND communicationChannel.communicationValue = null ) END ) \nAND orderTypeCode = '220' \nAND (orderCategory != 'EXCLUDED_CAT' OR orderCategory is not valued ) \nAND creationDateTime in (select RAW max(O2.creationDateTime) \nfrom `order` O2 WHERE ( LOWER(O2.buyer.contact.firstName) \nLIKE '%aziz%' OR LOWER(O2.buyer.contact.lastName) LIKE '%aziz%' \nOR ANY communicationChannel IN O2.buyer.contact.communicationChannel SATISFIES ( communicationChannel.communicationChannelCode = 'EMAIL' AND communicationChannel.communicationValue = null ) END ) \nAND ANY communicationChannel IN O2.buyer.contact.communicationChannel SATISFIES ( communicationChannel.communicationChannelCode = 'EMAIL' AND communicationChannel.communicationValue is not null ) END \nAND O2.orderTypeCode = '220' \nAND (O2.orderCategory != 'EXCLUDED_CAT'\nOR O2.orderCategory is not valued) \ngroup by ( ARRAY item.communicationValue FOR item IN O2.buyer.contact.communicationChannel WHEN item.communicationChannelCode = 'EMAIL' END ))"
}
When this query is executed in query monitor, it takes (2 seconds even if i have a little number of documents ~2000 ) :
elapsed: 1.93s | execution: 11.93s | count: 1 | size: 34
When executed from my spring boot application using spring data, it take double time (4 seconds).
Thanks for your help
It looks to me you are scanning the ORDER twice. Make sure if query using the ix1 only. If not specify USE INDEX
CREATE INDEX ix1 ON (ordertypecode, buyer.contact.firstname, buyer.contact.lastname, creationdatetime, ordercategory,buyer.contact.communicationchannel)
WHERE `_class` = "com.lbk.entities.OrderEntity";
SELECT SUM(o.cnt) AS count
FROM ( SELECT MAX([o1.creationdatetime,o1.cnt])[1] AS cnt
FROM (SELECT acomval, o2.creationdatetime, COUNT(1) AS cnt
FROM `ORDER` o2
LET acomval = (ARRAY ch.communicationvalue FOR ch IN o2.buyer.contact.communicationchannel
WHEN ch.communicationchannelcode = 'EMAIL' END )
WHERE (LOWER(o2.buyer.contact.firstname) LIKE '%aziz%'
OR LOWER(o2.buyer.contact.lastname) LIKE '%aziz%'
OR ANY ch IN o2.buyer.contact.communicationchannel
SATISFIES ( ch.communicationchannelcode = 'EMAIL' AND ch.communicationvalue IS NULL)
END
)
AND ANY ch IN o2.buyer.contact.communicationchannel
SATISFIES (ch.communicationchannelcode = 'EMAIL' AND ch.communicationvalue IS NOT NULL) END
AND o2.`_class` = "com.lbk.entities.OrderEntity"
AND o2.ordertypecode = '220'
AND ( o2.ordercategory != 'EXCLUDED_CAT' OR o2.ordercategory IS NOT VALUED)
GROUP BY acomval, o2.creationdatetime) AS o1
GROUP BY o1.acomval) AS o;

Unknown column 'Model1->Model2.fieldname' in 'on clause'

I have struggling in this error unknown column error.
I have 3 table the following are
Marketplace --- One to Many relationship (marketplace has many products.)
Product --- One to One relationship (Product belongs to marketplace)
Country -- One to many relationship (Country has many products.)
The sample JSON given below :
[{
"id": 1,
"name": "XYZ Name",
"code": "XYZCODE",
"Products": [
{
"id": 150,
"product_name": "ABC",
"product_location": 19,
"state_id": 24,
"city": "California",
"Country": {
"id": 19,
"name": "USA"
}
},
{
"id": 154,
"product_name": "DEF",
"product_location": 19,
"state_id": 24,
"city": "New York",
"Country": {
"id": 19,
"name": "USA"
}
}
]
}]
If am query city and Country name inside the Country table getting following error in sequelize
{
"code": "ER_BAD_FIELD_ERROR",
"errno": 1054,
"sqlState": "42S22",
"sqlMessage": "Unknown column 'Products->Country.name' in 'on clause'",
"sql": "SELECT `MarketplaceType`.`id`, `MarketplaceType`.`name`, `MarketplaceType`.`code`, `Products`.`id` AS `Products.id`, `Products`.`product_name` AS `Products.product_name`, `Products`.`product_location` AS `Products.product_location`, `Products`.`state_id` AS `Products.state_id`, `Products`.`city` AS `Products.city`, `Products->Country`.`id` AS `Products.Country.id`, `Products->Country`.`name` AS `Products.Country.name` FROM `marketplace_type` AS `MarketplaceType` LEFT OUTER JOIN `product` AS `Products` ON `MarketplaceType`.`id` = `Products`.`marketplace_type_id` AND `Products`.`status` = 1 AND `Products`.`marketplace_id` = 1 AND (`Products`.`city` = 'California' OR `Products->Country`.`name` = 'California') LEFT OUTER JOIN `country` AS `Products->Country` ON `Products`.`product_location` = `Products->Country`.`id` WHERE `MarketplaceType`.`status` = 1 AND `MarketplaceType`.`marketplace_id` = 1;"
}
AND MYSQL Query are following :
SELECT `MarketplaceType`.`id`, `MarketplaceType`.`name`, `MarketplaceType`.`code`, `Products`.`id` AS `Products.id`, `Products`.`product_name` AS `Products.product_name`, `Products`.`product_location` AS `Products.product_location`, `Products`.`state_id` AS `Products.state_id`, `Products`.`city` AS `Products.city`, `Products->Country`.`id` AS `Products.Country.id`, `Products->Country`.`name` AS `Products.Country.name` FROM `marketplace_type` AS `MarketplaceType` LEFT OUTER JOIN `product` AS `Products` ON `MarketplaceType`.`id` = `Products`.`marketplace_type_id` AND `Products`.`status` = 1 AND `Products`.`marketplace_id` = 1 AND (`Products`.`city` = 'California' OR `Products->Country`.`name` = 'California') LEFT OUTER JOIN `country` AS `Products->Country` ON `Products`.`product_location` = `Products->Country`.`id` WHERE `MarketplaceType`.`status` = 1 AND `MarketplaceType`.`marketplace_id` = 1;
ORM Query using sequelize :
var marketplaceTypeQueryObj = {};
var productCountQueryParames = {};
marketplaceTypeQueryObj['status'] = status["ACTIVE"];
marketplaceTypeQueryObj['marketplace_id'] = marketplace['WHOLESALE'];
productCountQueryParames['status'] = status["ACTIVE"];
productCountQueryParames['marketplace_id'] = marketplace['WHOLESALE'];
if (req.query.origin) {
productCountQueryParames['$or'] = [{
city: req.query.origin
}, {
'$Products.Country.name$': req.query.origin
}, {
'$Products.State.name$': req.query.origin
}];
}
console.log('productCountQueryParames', productCountQueryParames);
model['MarketplaceType'].findAll({
where: marketplaceTypeQueryObj,
include: [{
model: model['Product'],
where: productCountQueryParames,
include: [{
model: model['Country'],
attributes: ['id', 'name']
}, {
model: model['State'],
attributes: ['id', 'name']
}],
attributes: ['id', 'product_name', 'product_location', 'state_id', 'city'],
required: false
}],
attributes: ['id', 'name', 'code']
})
Change
attributes: ['id', 'product_name', 'product_location', 'state_id', 'city'],
to
attributes: ['id', 'product_name', 'product_location', 'state_id', 'city','country_id'],
Add country id in your product model attributes

Postgres + Sequelize: How to read function result?

I have a function payment_summary() as below:
CREATE OR REPLACE FUNCTION payment_summary()
RETURNS SETOF PAYMENT_SUMMARY_TYPE
LANGUAGE plpgsql
AS $$
DECLARE
payment_sum payment_summary_type%ROWTYPE;
BEGIN
FOR payment_sum IN SELECT
pay.application_no,
project.title,
pay.payment_rec,
customer.cust_name,
project.estimated_cost,
(project.estimated_cost - pay.payment_rec) AS outstanding_amt
FROM project
INNER JOIN customer
ON project.customer_cust_id = customer.cust_id
INNER JOIN
(SELECT
project.application_no,
sum(payment.amount) AS payment_rec
FROM payment
INNER JOIN project
ON payment.project_id = project.project_id
WHERE payment.drcr_flg = 'Cr'
GROUP BY project.application_no) AS pay
ON pay.application_no = project.application_no
LOOP
RETURN NEXT payment_sum;
END LOOP;
END;
$$;
PAYMENT_SUMMARY_TYPE is defined as:
CREATE TYPE PAYMENT_SUMMARY_TYPE AS
(
application_no VARCHAR(150),
title VARCHAR(500),
payment_rec INTEGER,
customer_name VARCHAR(500),
estimated_cost INTEGER,
outstanding_amt INTEGER
);
Using below code to execute the function and get results:
sequelize.query('SELECT payment_summary()').then(function(data) {
res.json(data);
});
Getting below as response:
[
[
{
"payment_summary": "(716,\"C1\",100000,\"C1 - city\",0,-100000)"
},
{
"payment_summary": "(716,\"C2\",100000,\"C2 - city\",0,-100000)"
}
],
{
"command": "SELECT",
"rowCount": 2,
"oid": null,
"rows": [
{
"payment_summary": "(716,\"C1\",100000,\"C1 - city\",0,-100000)"
},
{
"payment_summary": "(716,\"C2\",100000,\"C2 - city\",0,-100000)"
}
],
"fields": [
{
"name": "payment_summary",
"tableID": 0,
"columnID": 0,
"dataTypeID": 17453,
"dataTypeSize": -1,
"dataTypeModifier": -1,
"format": "text"
}
],
"_parsers": [
null
],
"rowAsArray": false
}
]
I need the response in below format:
[
{
application_no: 716,
title: "C1",
payment_rec : 100000,
customer_name : "C1 - city"
estimated_cost : 0
outstanding_amt : -100000
},
{
application_no: 717,
title: "C2",
payment_rec : 100000,
customer_name : "C2 - city"
estimated_cost : 0
outstanding_amt : -100000
}
]
How can i read / convert the response in required format ?