Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nocobase/plugin-china-region

Package Overview
Dependencies
Maintainers
1
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nocobase/plugin-china-region - npm Package Compare versions

Comparing version 0.7.0-alpha.8 to 0.7.0-alpha.9

9

esm/server.js

@@ -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,2 +32,9 @@ 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) => ({

@@ -34,0 +41,0 @@ code: item.code,

15

lib/server.js

@@ -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,3 +35,10 @@ class ChinaRegionPlugin extends server_1.Plugin {

const ChinaRegion = this.db.getModel('chinaRegions');
yield ChinaRegion.bulkCreate(china_division_1.provinces.map((item) => ({
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) => ({
code: item.code,

@@ -41,3 +48,3 @@ name: item.name,

})));
yield ChinaRegion.bulkCreate(china_division_1.cities.map((item) => ({
yield ChinaRegion.bulkCreate(cities.map((item) => ({
code: item.code,

@@ -48,3 +55,3 @@ name: item.name,

})));
yield ChinaRegion.bulkCreate(china_division_1.areas.map((item) => ({
yield ChinaRegion.bulkCreate(areas.map((item) => ({
code: item.code,

@@ -51,0 +58,0 @@ name: item.name,

{
"name": "@nocobase/plugin-china-region",
"version": "0.7.0-alpha.8",
"version": "0.7.0-alpha.9",
"main": "lib/index.js",

@@ -21,5 +21,5 @@ "license": "Apache-2.0",

"devDependencies": {
"@nocobase/test": "0.7.0-alpha.8"
"@nocobase/test": "0.7.0-alpha.9"
},
"gitHead": "f4a12279b43669f2c0dcb3c98b87ebf03d8dab0b"
"gitHead": "79d5b309fb92148162bfedfb7e304b4673faf568"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc