Rameshwar Bhaskar
08/04/2023, 3:06 PMfwreinit=1 it returns
{
"data": [
{
"id": "36573E28-C77A-4A80-960502795ED74EA8",
"product_name": "Gold Biscuits",
"price": 200.45,
"product_weight": 20.55,
"product_quantity": 500,
"sell_type_id": "2",
"currency_name": "doller",
"currency_symbols": "$",
"is_faveriote": 0
},
{
"id": "3DD63A64-4F7B-4AAB-A2D939DAA082638C",
"product_name": "Gold Biscuits",
"price": 200.45,
"product_weight": 20.55,
"product_quantity": 500,
"sell_type_id": "2",
"currency_name": "doller",
"currency_symbols": "$",
"is_faveriote": 0
},
{
"id": "621478A7-A4C8-4CC1-B1DA41EB2A4767AE",
"product_name": "Gold Biscuits",
"price": 200.45,
"product_weight": 20.36,
"product_quantity": 500,
"sell_type_id": "2",
"currency_name": "doller",
"currency_symbols": "$",
"is_faveriote": 0
},
{
"id": "7DB43EF3-A28E-4C3E-8021A3AAF940C29E",
"product_name": "Gold Biscuits",
"price": 200.45,
"product_weight": 20.36,
"product_quantity": 500,
"sell_type_id": "2",
"currency_name": "doller",
"currency_symbols": "$",
"is_faveriote": 0
},
{
"id": "82078755-9227-452C-B1E99CD436C0EC86",
"product_name": "Gold Biscuits",
"price": 200.45,
"product_weight": 20.36,
"product_quantity": 500,
"sell_type_id": "2",
"currency_name": "doller",
"currency_symbols": "$",
"is_faveriote": 0
},
{
"id": "99495A34-0A18-4C8A-A7DF09223BF9A19C",
"product_name": "Gold Biscuits",
"price": 200.45,
"product_weight": 20.36,
"product_quantity": 500,
"sell_type_id": "2",
"currency_name": "doller",
"currency_symbols": "$",
"is_faveriote": 0
},
{
"id": "DE9F109C-ABF8-4816-A54119D988B16621",
"product_name": "Gold Biscuits",
"price": 200.45,
"product_weight": 20.36,
"product_quantity": 500,
"sell_type_id": "2",
"currency_name": "doller",
"currency_symbols": "$",
"is_faveriote": 0
}
],
"error": false,
"pagination": {
"totalPages": 1,
"maxRows": 0,
"offset": 0,
"page": 1,
"totalRecords": 0
},
"messages": [
"Fetched all products"
]
}
and without fwreinit
it returns the error
{
"data": {
"environment": {
"currentRoutedUrl": "api/products/",
"timestamp": "2023-08-04T15:03:40Z",
"currentRoute": "api/products/",
"currentEvent": "API.Product.index"
},
"exception": {
"stack": [
"G:\\WorkNew\\Stackur\\Stackur\\modules\\qb\\models\\Grammars\\BaseGrammar.cfc:116",
"G:\\WorkNew\\Stackur\\Stackur\\modules\\qb\\models\\Query\\QueryBuilder.cfc:3559",
"G:\\WorkNew\\Stackur\\Stackur\\modules\\qb\\models\\Query\\QueryBuilder.cfc:3512",
"G:\\WorkNew\\Stackur\\Stackur\\modules\\qb\\models\\Query\\QueryBuilder.cfc:3264",
"G:\\WorkNew\\Stackur\\Stackur\\models\\API\\ProductService.cfc:90",
"G:\\WorkNew\\Stackur\\Stackur\\handlers\\API\\Product.cfc:44",
"G:\\WorkNew\\Stackur\\Stackur\\coldbox\\system\\RestHandler.cfc:58",
"G:\\WorkNew\\Stackur\\Stackur\\coldbox\\system\\web\\Controller.cfc:998",
"G:\\WorkNew\\Stackur\\Stackur\\coldbox\\system\\web\\Controller.cfc:713",
"G:\\WorkNew\\Stackur\\Stackur\\coldbox\\system\\Bootstrap.cfc:290",
"G:\\WorkNew\\Stackur\\Stackur\\coldbox\\system\\Bootstrap.cfc:506",
"G:\\WorkNew\\Stackur\\Stackur\\Application.cfc:115"
],
"detail": "",
"type": "database",
"extendedInfo": ""
}
},
"error": true,
"pagination": {
"totalPages": 1,
"maxRows": 0,
"offset": 0,
"page": 1,
"totalRecords": 0
},
"messages": [
"An exception ocurred: Not unique table/alias: 'currency'"
]
}
the code goes here
function getAllProducts(required string userId){
local.product = queryBuilder.from('products').where('products.active', 1)
.where('products.status', 1)
.join('currency', 'currency.id','=', 'products.currency_id') //
.join('metal_type', 'metal_type.id','=', 'products.metal_type_id')
.join('product_weight', 'product_weight.id', '=', 'products.product_weight_id')
.select(['products.id', 'products.product_name', 'products.price', 'products.product_weight', 'products.product_quantity', 'products.sell_type_id', 'currency.name as currency_name', 'currency.symbol as currency_symbols',])
.get();
return local.product;
}aliaspooryorik
aliaspooryorik
Rameshwar Bhaskar
08/04/2023, 3:36 PM