@eeplatform/core 1.8.6 → 1.8.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eeplatform/core
2
2
 
3
+ ## 1.8.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 7bef39f: Add psgc index
8
+
3
9
  ## 1.8.6
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -762,6 +762,7 @@ declare function usePSGCRepo(): {
762
762
  prefix?: string;
763
763
  type?: string;
764
764
  }) => Promise<TPSGC | null>;
765
+ setRegionProvinceName: () => Promise<"Successfully set region name as province name for cities." | undefined>;
765
766
  };
766
767
 
767
768
  declare function usePSGCController(): {
package/dist/index.js CHANGED
@@ -6250,6 +6250,40 @@ function usePSGCRepo() {
6250
6250
  throw new import_nodejs_utils33.InternalServerError("Failed to delete PSGC.");
6251
6251
  }
6252
6252
  }
6253
+ async function setRegionProvinceName() {
6254
+ try {
6255
+ const cities = await collection.find({ type: { $in: ["City", "Mun"] } }).toArray();
6256
+ for (let index = 0; index < cities.length; index++) {
6257
+ const city = cities[index];
6258
+ if (city.region) {
6259
+ continue;
6260
+ }
6261
+ const province = await collection.findOne({
6262
+ type: "Prov",
6263
+ code: { $regex: `^${city.code.substring(0, 5)}` }
6264
+ });
6265
+ if (province) {
6266
+ await collection.updateOne(
6267
+ { _id: city._id },
6268
+ { $set: { province: province.name } }
6269
+ );
6270
+ }
6271
+ const region = await collection.findOne({
6272
+ type: "Reg",
6273
+ code: { $regex: `^${city.code.substring(0, 2)}` }
6274
+ });
6275
+ if (region) {
6276
+ await collection.updateOne(
6277
+ { _id: city._id },
6278
+ { $set: { region: region.name } }
6279
+ );
6280
+ }
6281
+ }
6282
+ return "Successfully set region name as province name for cities.";
6283
+ } catch (error) {
6284
+ console.log(error);
6285
+ }
6286
+ }
6253
6287
  return {
6254
6288
  createIndexes,
6255
6289
  add,
@@ -6257,7 +6291,8 @@ function usePSGCRepo() {
6257
6291
  getById,
6258
6292
  updateFieldById,
6259
6293
  deleteById,
6260
- getByName
6294
+ getByName,
6295
+ setRegionProvinceName
6261
6296
  };
6262
6297
  }
6263
6298