@digione/node-custom-api 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/user.js +6 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digione/node-custom-api",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Typescript node digione-api",
5
5
  "author": "Monchai Jirayupong <monchai.j@seven.co.th>",
6
6
  "license": "MIT",
package/utils/user.js CHANGED
@@ -225,8 +225,9 @@ const getAddressIndex = (data, { condition = {}, lang_code = "en" } = {}) => tsl
225
225
  bol = (typeof result['country_id'] == "undefined");
226
226
  }
227
227
  if (!bol && data['state'] && !condition['state_id']) {
228
+ let country_id = condition['country_id'] || null;
228
229
  let state = yield state_1.StateModel.schema("core", "_").findOne({
229
- raw: true, where: Object.assign(Object.assign(Object.assign({}, where), _.pick(condition, ['country_id'])), { state_name: data['state'] }), attributes: ['id'], order
230
+ raw: true, where: Object.assign(Object.assign({}, where), { country_id, state_name: data['state'] }), attributes: ['id'], order
230
231
  });
231
232
  if (state) {
232
233
  result['state_id'] = state['id'];
@@ -235,8 +236,9 @@ const getAddressIndex = (data, { condition = {}, lang_code = "en" } = {}) => tsl
235
236
  bol = (typeof result['state_id'] == "undefined");
236
237
  }
237
238
  if (!bol && data['city'] && !condition['city_id']) {
239
+ let state_id = condition['state_id'] || null;
238
240
  let city = yield city_1.CityModel.schema("core", "_").findOne({
239
- raw: true, where: Object.assign(Object.assign(Object.assign({}, where), _.pick(condition, ['state_id'])), { city_name: data['city'] }), attributes: ['id'], order
241
+ raw: true, where: Object.assign(Object.assign({}, where), { state_id, city_name: data['city'] }), attributes: ['id'], order
240
242
  });
241
243
  if (city) {
242
244
  result['city_id'] = city['id'];
@@ -245,8 +247,9 @@ const getAddressIndex = (data, { condition = {}, lang_code = "en" } = {}) => tsl
245
247
  bol = (typeof result['city_id'] == "undefined");
246
248
  }
247
249
  if (!bol && data['district']) {
250
+ let city_id = condition['city_id'] || null;
248
251
  let district = yield district_1.DistrictModel.schema("core", "_").findOne({
249
- raw: true, where: Object.assign(Object.assign(Object.assign({}, where), _.pick(condition, ['city_id'])), { district_name: data['district'] }), attributes: ['id'], order
252
+ raw: true, where: Object.assign(Object.assign({}, where), { city_id, district_name: data['district'] }), attributes: ['id'], order
250
253
  });
251
254
  if (district)
252
255
  result['district_id'] = district['id'];