随笔分类 - nodeJS笔记
摘要:const Core = require('@alicloud/pop-core'); const accessKeyId = "xxxx" const accessSecret = "xxxxO" var client = new Core({ accessKeyId: accessKeyId,
阅读全文
摘要:nestjs,mongoose关联查询网上搜不到了,查看了nest/mongoose.d.ts文件,分享一波 user.model.ts import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose" import { Document,
阅读全文
摘要:export declare enum CronExpression { EVERY_SECOND = "* * * * * *", EVERY_5_SECONDS = "*/5 * * * * *", EVERY_10_SECONDS = "*/10 * * * * *", EVERY_30_SE
阅读全文
摘要:1.验证枚举类型 var schema = { "properties": { "data": { "type": "object", "required": ["code", "status", "message", "data", "token"], "properties": { "code"
阅读全文
摘要:1.事务 try { const transaction = await sequelize.transaction(); const user = await User.findOne(..., { transaction }); await user.update(..., { transact
阅读全文
摘要:const num = String(1232323.110); function formatNum(num){ //一位或三位数字,后边是 有三位数组一组的(1个或多个), 然后匹配结束或者. ,?=,?:参与格式匹配,不参与结果匹配,$1为 (\d{1,3})的匹配结果 return Stri
阅读全文
摘要:MongoError: command find requires authentication at Connection.<anonymous> (/home/Map/node_modules/mongodb-core/lib/connection/pool.js:443:61) at Conn
阅读全文
摘要://方法1 var proxy = require('express-http-proxy'); app.use('/map', proxy('https://test.baidu.com/', { proxyReqPathResolver: function (req, res) { consol
阅读全文
摘要:const Redis = require("ioredis"); const redis = new Redis({ port: 6300, // Redis port host: '192.168.50.111', // Redis host password: '123', db: 0, })
阅读全文
摘要:说明:暂不支持egg-mysql动态数据源,用到动态数据源请自行修改。欢迎各位大佬指导。。。 集群配置: exports.mysql = { // 单数据库信息配置 client: { db1: { // host host: 'ip1', // 端口号 port: '3306', // 用户名 u
阅读全文
摘要:参考:https://kafka.js.org/docs 确保同一个消息发送到同一个partition,一个topic,一个partition,一个consumer,内部单线程消费1.封装kafkaUtil类const { Kafka, logLevel } = require('kafkajs')
阅读全文
摘要:db.getCollection('geoServer').update({},{$unset:{longitude:null,latitude:null}},{ multi: true}) 实测有效,拿去吧
阅读全文
摘要://国测局坐标(火星坐标,比如高德地图在用),百度坐标,wgs84坐标(谷歌国外以及绝大部分国外在线地图使用的坐标)var coordtransform=require('coordtransform');// //百度经纬度坐标转国测局坐标// var bd09togcj02=coordtrans
阅读全文
摘要:详情参考 http://nodejs.cn/api/crypto.html, http://nodejs.cn/api/buffer.html 利用 openssl 生成公钥私钥 生成公钥: openssl genrsa -out privateKey.pem 1024 生成私钥: openssl
阅读全文
摘要:一 、String 类 1. mysql 常用函数 length, concat, substr, upper, lower, trim,ifnull,isnull; 如果中文字段乱码: set names gbk; 2. 其他函数 (1) lpad, 左边用 \* 号填充, 总字符串为长度为 10
阅读全文
摘要:mysql.js const mysql = require("mysql"); const poolCluster = mysql.createPoolCluster({ removeNodeErrorCount: 1, // Remove the node immediately when co
阅读全文
摘要:1.启动eggjs pm2 start npm --name eggjs -- run dev 修改代码,无需重启
阅读全文
摘要:话不多说,直接复制即用。。。 function regIdCard(idcode) { const weight_factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; const check_code = ['1', '0',
阅读全文
摘要:const Redis = require('ioredis'); const {getmac)= require(' getmac'); getmac();//获取mac地址 const cache = new Redis({ port: 6300, // Redis port host: "19
阅读全文
摘要:const mysql = require('mysql'); const config = require('../config/config'); const poolCluster = mysql.createPoolCluster({ removeNodeErrorCount: 1, //
阅读全文

浙公网安备 33010602011771号