@nocobase/plugin-china-region
Advanced tools
Comparing version 0.7.0-alpha.17 to 0.7.0-alpha.18
@@ -10,4 +10,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { Database } from '@nocobase/database'; | ||
import { Plugin } from '@nocobase/server'; | ||
import { areas, cities, provinces } from 'china-division'; | ||
import { resolve } from 'path'; | ||
@@ -32,9 +32,2 @@ export class ChinaRegionPlugin extends Plugin { | ||
const ChinaRegion = this.db.getModel('chinaRegions'); | ||
const db = new Database({ | ||
dialect: 'sqlite', | ||
storage: resolve(process.cwd(), 'node_modules/china-division/dist/data.sqlite'), | ||
}); | ||
const [provinces] = yield db.sequelize.query('SELECT `code`, `name` FROM `province`'); | ||
const [cities] = yield db.sequelize.query('SELECT `code`, `name`, `provinceCode` FROM `city`'); | ||
const [areas] = yield db.sequelize.query('SELECT `code`, `name`, `cityCode` FROM `area`'); | ||
yield ChinaRegion.bulkCreate(provinces.map((item) => ({ | ||
@@ -41,0 +34,0 @@ code: item.code, |
@@ -13,4 +13,4 @@ "use strict"; | ||
exports.ChinaRegionPlugin = void 0; | ||
const database_1 = require("@nocobase/database"); | ||
const server_1 = require("@nocobase/server"); | ||
const china_division_1 = require("china-division"); | ||
const path_1 = require("path"); | ||
@@ -35,10 +35,3 @@ class ChinaRegionPlugin extends server_1.Plugin { | ||
const ChinaRegion = this.db.getModel('chinaRegions'); | ||
const db = new database_1.Database({ | ||
dialect: 'sqlite', | ||
storage: (0, path_1.resolve)(process.cwd(), 'node_modules/china-division/dist/data.sqlite'), | ||
}); | ||
const [provinces] = yield db.sequelize.query('SELECT `code`, `name` FROM `province`'); | ||
const [cities] = yield db.sequelize.query('SELECT `code`, `name`, `provinceCode` FROM `city`'); | ||
const [areas] = yield db.sequelize.query('SELECT `code`, `name`, `cityCode` FROM `area`'); | ||
yield ChinaRegion.bulkCreate(provinces.map((item) => ({ | ||
yield ChinaRegion.bulkCreate(china_division_1.provinces.map((item) => ({ | ||
code: item.code, | ||
@@ -48,3 +41,3 @@ name: item.name, | ||
}))); | ||
yield ChinaRegion.bulkCreate(cities.map((item) => ({ | ||
yield ChinaRegion.bulkCreate(china_division_1.cities.map((item) => ({ | ||
code: item.code, | ||
@@ -55,3 +48,3 @@ name: item.name, | ||
}))); | ||
yield ChinaRegion.bulkCreate(areas.map((item) => ({ | ||
yield ChinaRegion.bulkCreate(china_division_1.areas.map((item) => ({ | ||
code: item.code, | ||
@@ -58,0 +51,0 @@ name: item.name, |
{ | ||
"name": "@nocobase/plugin-china-region", | ||
"version": "0.7.0-alpha.17", | ||
"version": "0.7.0-alpha.18", | ||
"main": "lib/index.js", | ||
@@ -21,5 +21,5 @@ "license": "Apache-2.0", | ||
"devDependencies": { | ||
"@nocobase/test": "0.7.0-alpha.17" | ||
"@nocobase/test": "0.7.0-alpha.18" | ||
}, | ||
"gitHead": "86611313d348791ad62be3803fa62535a9582fc4" | ||
"gitHead": "400167fe0cd2b29337bd4e2873ecc6894147f5f8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32377
259