@digione/node-custom-api 0.1.9-alpha8 → 0.1.9-alpha9
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.
- package/package.json +1 -1
- package/utils/user.js +5 -6
package/package.json
CHANGED
package/utils/user.js
CHANGED
|
@@ -230,11 +230,10 @@ const convertAddress = (data, { lang_code = "en", transform = false } = {}) => t
|
|
|
230
230
|
});
|
|
231
231
|
exports.convertAddress = convertAddress;
|
|
232
232
|
const getAddressIndex = (data, { condition = {}, lang_code = "en" } = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
233
|
-
let result = {},
|
|
234
|
-
let order = [sequelize.literal(`FIELD(lang_code,${'\'' + where['lang_code'].join('\',\'') + '\''})`)];
|
|
233
|
+
let result = {}, bol = false;
|
|
235
234
|
if (!bol && data['country'] && !condition['country_id']) {
|
|
236
235
|
let country = yield country_1.CountryModel.schema("core", "_").findOne({
|
|
237
|
-
raw: true, where:
|
|
236
|
+
raw: true, where: { country_name: data['country'] }, attributes: ['id']
|
|
238
237
|
});
|
|
239
238
|
if (country) {
|
|
240
239
|
result['country_id'] = country['id'];
|
|
@@ -245,7 +244,7 @@ const getAddressIndex = (data, { condition = {}, lang_code = "en" } = {}) => tsl
|
|
|
245
244
|
if (!bol && data['state'] && !condition['state_id']) {
|
|
246
245
|
let country_id = condition['country_id'] || null;
|
|
247
246
|
let state = yield state_1.StateModel.schema("core", "_").findOne({
|
|
248
|
-
raw: true, where:
|
|
247
|
+
raw: true, where: { country_id, state_name: data['state'] }, attributes: ['id']
|
|
249
248
|
});
|
|
250
249
|
if (state) {
|
|
251
250
|
result['state_id'] = state['id'];
|
|
@@ -256,7 +255,7 @@ const getAddressIndex = (data, { condition = {}, lang_code = "en" } = {}) => tsl
|
|
|
256
255
|
if (!bol && data['city'] && !condition['city_id']) {
|
|
257
256
|
let state_id = condition['state_id'] || null;
|
|
258
257
|
let city = yield city_1.CityModel.schema("core", "_").findOne({
|
|
259
|
-
raw: true, where:
|
|
258
|
+
raw: true, where: { state_id, city_name: data['city'] }, attributes: ['id']
|
|
260
259
|
});
|
|
261
260
|
if (city) {
|
|
262
261
|
result['city_id'] = city['id'];
|
|
@@ -267,7 +266,7 @@ const getAddressIndex = (data, { condition = {}, lang_code = "en" } = {}) => tsl
|
|
|
267
266
|
if (!bol && data['district']) {
|
|
268
267
|
let city_id = condition['city_id'] || null;
|
|
269
268
|
let district = yield district_1.DistrictModel.schema("core", "_").findOne({
|
|
270
|
-
raw: true, where:
|
|
269
|
+
raw: true, where: { city_id, district_name: data['district'] }, attributes: ['id']
|
|
271
270
|
});
|
|
272
271
|
if (district)
|
|
273
272
|
result['district_id'] = district['id'];
|