NBNPI4ATCXHIMKSXW5VRS3KM4WJZZMOPD7H4QTDNOQFRSQYFSIBAC
XQA3IQXSGAO2FST3F64WLVZ7JNLMQYKT3LO4SHHKYR2D765OPGHQC
Z7XOXXDJ7T6E4ZCP2AK5YSXWE6TCDCLZEXAZPZZVLOY4WCFVZPHAC
72DUSPYXB64ECTFQWWD7XSY4YJUNRCFZT22AS4BDRIIUZP33CZGAC
E4HFJ4L4PAGV7R7EXVG2B2CWDGGW7XWU4D37VURZ66HZ3ILHCFUAC
63VXWIHIAKGK7J4VTNRUAG2V32N2QUSWFELB6GD34S54FGRWAPCQC
WYTMZJFYVKHR4QH7AV5JUNWXT6NAC5NNQNPZCQSDI6LGI7DVXFYAC
BPHFBV52V4OA6WLKXGFK7Q4IM5EUS2SKAW5ZGSA6K3NJFJJVATIAC
DCYC55MAVFDM43TEEUMAHLPOHNQ3EJ5PEVCA7H6ZTKNQHJZK7XJAC
RGMMX4YQP6NPCPFAGZ5SRITSPJQW4F77S6RJLYJMS3D732LUGDPQC
create or replace function get_store(_store_id integer) returns table(name text, url text, address text, images json, times json, timezone text, phone packed_phone_number, partner boolean, delivery boolean, pickup boolean, prepayment boolean) as $$
create or replace function get_stores() returns table(
id integer,
name text,
url text,
address text,
longitude decimal,
latitude decimal,
images json,
times json,
timezone text,
phone packed_phone_number,
partner boolean,
delivery boolean,
pickup boolean,
prepayment boolean
) as $$
let stores = (await pool.query(`select distinct on(store_id) store_id, name, longitude, latitude, store_image.url from store left outer join store_image using (store_id)`)).rows;
let stores = (await pool.query(`select * from get_stores()`)).rows;
case 'store': {
let s = Number(parameters.id);
let data = 'invalid id';
if(Number.isInteger(s)) {
let response = (await pool.query(`select * from get_store($1)`, [s])).rows;
if(response.length === 0) {
data = 'store not found';
} else {
data = response[0];
//ws.subscribe('store/' + parameters.store);
}
}
ws.send(JSON.stringify({
response_ID: request_ID,
data: data
}));
break;
}