0.0.48 • Published 3 years ago

@medomino-170/utils v0.0.48

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

medo-ts2

build 文件夹是生成好的 js 文件和 .d.ts

crypto-js 3.3.0 最新版(4.x)打包体积过大

how to use

数组相关方法

byte-conversion

import { byteConversion } from "../../ts/byte-conversion";

console.log(byteConversion(1000))

deepcopy

import { deepCopy, deepProxy } from "../../src/deepcopy";
import { Logger } from "../../src/logjs-extend";

const a = { a: 1 };
Object.freeze(a)
const max = 1e5;
const logger = new Logger();
for (let i = 0; i < max; i++) {
  // const b = deepCopy(a)
  // b.a = 123
  const b = deepProxy(a, (a) => {
    a.a = 123;
  });
}
logger.log("done");

mongo

import { mongoConfigs } from "../../../../private/medomino/build/datebase/index";
import { Mongo } from "../../ts/mongo";

const mongoConfig = {
  url: `${mongoConfigs.url}/medo_mango?authSource=admin`,
  option: {
    useUnifiedTopology: true,
    useNewUrlParser: true,
    minPoolSize: 2,
    maxPoolSize: 100,
  },
};

const mgsql = new Mongo(mongoConfig);

async function init() {

  for (let i = 0; i < 100; i++) {
    await mgsql.find({
      table: "std_doctor",
      query: {},
      limit: 1,
    });
  }

  // const data = await mgsql.find({
  //   table: "std_doctor",
  //   query: {},
  //   limit: 1,
  // });


  process.exit();
}

init();

mysql

import { Mysql } from "../../ts/mysql/index";
import { mysqlConf } from "../../configs/index";
import { Logger } from "../../ts/logjs-extend";

const mysql = new Mysql(mysqlConf);

async function init() {
  const table = "nlp_entity";
  const limit = 1e5;
  const db = "new_beigene_demo_2021";
  // const ids: { id: string }[] = await mysql.query(
  //   `select id from ?? where type = '疾病' and value = '肿瘤'`,
  //   [table],
  //   db
  // );
  // const id = ids.map((x) => x.id);

  // console.log(ids.length);

  // const logger = new Logger();

  // // const data = await mysql.query(`select id from ?? where id in (?)`, [table, id], db)

  // const extend =
  //   `SELECT ? AS id UNION ALL ` +
  //   Array(id.length - 1)
  //     .fill(`SELECT ?`)
  //     .join(" UNION ALL ");
  // const params = id;

  // console.log(`SELECT id from (${extend}) AS a LEFT JOIN ?? AS b ON a.id = b.id`)
  // console.log(params.concat([table]))

  // const data = await mysql.query(
  //   `SELECT a.id from (${extend}) AS a LEFT JOIN ?? AS b ON a.id = b.id where b.id is not null`,
  //   params.concat([table]),
  //   db
  // );

  // const data = await mysql.query(
  //   `SELECT a.id from ?? as a inner join (${extend}) AS b ON a.id = b.id `,
  //   [table].concat(params),
  //   db
  // );

  // const data = await mysql.joinIn({
  //   table,
  //   ids: id,
  //   key: "id",
  //   fields: ["id"],
  //   db,
  //   custom: 'distinct a.rid'
  // });

  // console.log(data.length)

  // logger.log("done");

  // const data = await mysql.query(`show databases`, [table]);

  const data = await mysql.query(`select * from ?? limit 10`, [table], db);


  // const data = await mysql.joinIn({
  //   table,
  //   ids: ["000004ffaa584902eaa33421d4073137"],
  //   key: "id",
  //   fields: ["id"],
  //   // db,
  //   custom: "distinct a.rid",
  // });

  console.log(data);

  // process.exit();
}

init();

postgresql

import { PostgreSql } from "../../src/postgresql";
import { Logger } from "../../src/logjs-extend";
import { fse, path } from "../../src/fse";

import { pgsqlConfigs } from "../../../../private/medomino/build/datebase";

const pgsql = new PostgreSql({
  host: pgsqlConfigs.host,
  port: pgsqlConfigs.port,
  user: pgsqlConfigs.username,
  password: pgsqlConfigs.password,
  database: "medo_master",
});

async function init() {
  // const data = await pgsql.query(`select rid from ask_normalization limit ?`, [
  //   1e4
  // ]);

  // await fse.writeJSON(path.join(__dirname, '1.json'), data)

  let data: any[] = await fse.readJSON(path.join(__dirname, "1.json"));
  data = data.concat(data);
  // data = data.concat(data)
  // data = data.concat(data)
  // data = data.concat(data)
  // data = data.concat(data)

  console.log(data.length);

  const logger = new Logger();

  // SELECT regexp_split_to_table(?, ',' ) AS id

  // const res = await pgsql.query(`select rid from ask_normalization where rid in (?)`, [data.map(x => x.rid)])
  // const res = await pgsql.query(`select rid from ask_normalization where rid in (SELECT regexp_split_to_table(?, ',' ) AS id)`, [data.map(x => x.rid).join()])
  // const res = await pgsql.query(`SELECT regexp_split_to_table(?, ',' ) AS id`, [data.map(x => x.rid).join()])
  const res = await pgsql.query(
    `SELECT rid FROM ask_normalization WHERE EXISTS (SELECT 1 FROM (SELECT regexp_split_to_table(?, ',' ) AS id) as a WHERE a.id = ask_normalization.rid);`,
    [data.map((x) => x.rid).join()]
  );

  // for (let i = 0; i < 1; i++) {
  //   const res = await pgsql.joinIn({
  //     table: "ask_normalization",
  //     key: "rid",
  //     ids: data.map((x) => x.rid),
  //     fields: ["rid"],
  //   });
  //   console.log(res.length, 'res')
  //   // const res = await pgsql.query(
  //   //   `SELECT regexp_split_to_table(?, ',' ) AS id`,
  //     // [data.map(x => x.rid).join()]
  //   // );
  //   logger.log(`${i + 1} / ${10}`);
  // }

  logger.log("done");
  process.exit();
}

init();

typescript 相关基础方法

import { MedoTypes, MedoTypesM } from "../../ts/types";

console.log(MedoTypesM.getKeys);

type d = MedoTypes.GetKeys<{}>;
0.0.48

3 years ago

0.0.46

3 years ago

0.0.47

3 years ago

0.0.44

3 years ago

0.0.45

3 years ago

0.0.43

3 years ago

0.0.40

3 years ago

0.0.41

3 years ago

0.0.42

3 years ago

0.0.38

3 years ago

0.0.39

3 years ago

0.0.37

3 years ago

0.0.36

3 years ago

0.0.33

3 years ago

0.0.34

3 years ago

0.0.35

3 years ago

0.0.32

3 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.20

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago