原创 eggjs中egg-mysql不支持mysql集羣,代碼修改爲支持集羣
說明:暫不支持egg-mysql動態數據源,用到動態數據源請自行修改。歡迎各位大佬指導。。。 集羣配置: exports.mysql = { // 單數據庫信息配置 client: { db1: {
原创 nodejs中的kafkajs,消費順序,不重複消費
參考:https://kafka.js.org/docs 1.封裝kafkaUtil類const { Kafka, logLevel } = require('kafkajs') //const cache = requi
原创 mongodb地理位置座標加了索引,操作時報錯 Location object expected, location array not in correct format
別猶豫了,將座標中的數據改爲數字類型即可,如: location:[113.45,34,191]
原创 mongodb刪除指定字段
db.getCollection('geoServer').update({},{$unset:{longitude:null,latitude:null}},{ multi: true}) 實測有效,拿去吧
原创 nodejs 公私鑰文件加密解密
詳情參考 http://nodejs.cn/api/crypto.html, http://nodejs.cn/api/buffer.html 利用 openssl 生成公鑰私鑰 生成公鑰: openssl genrsa -o
原创 mysql基礎知識
一、String 類 1. mysql 常用函數 length, concat, substr, upper, lower, trim,ifnull,isnull 2. 其他函數 (1) lpad, 左邊用 \* 號填充, 總字符串
原创 pm2 啓動eggjs,
1.啓動eggjs pm2 start npm --name eggjs -- run dev 修改代碼,無需重啓
原创 js身份證驗證,二代身份證,大陸,權重驗證,正規
---------話不多說,直接複製即用。。。------- function regIdCard(idcode) { const weight_factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7,
原创 nodejs限制IP一段時間內的訪問次數
const Redis = require('ioredis'); const cache = new Redis({ port: 6300, // Redis port host: "192.100.50.256",
原创 nodejs鏈接mysql集羣
const mysql = require('mysql2'); const config = require('../config/config'); module.exports = async (sql, options) => {
原创 nodejs,mysql語句in的寫法
exports.findTest = async()=>{ const ids = ['b3bc6e3dbb2a420aa8d569d70283e4ed', '6fa0671fd75d418398b5ab4a35bfe21d'] cons
原创 js分時函數
qq中有10000個好友,每秒中渲染20個好友: var timeChunk = function(arr, fn, count) { var t; var start = function() { for(var i = 0; i
原创 js單例模式
1.通用模式 var getSingle = function( fn ){ var result; return function(
原创 js節流和防抖
節流: 1. var throttle = function(fn,delay){ var pre = Date.now(); return function(){ v
原创 地址值
1. const obj1 ={ name:'a' } const obj2 = { name: 'a' } const arr = [1,2,3]; const arr2 = [1,2,3] console.log(obj1 == ob