1.2.0 • Published 12 months ago
core-installer v1.2.0
CORE-Installer
Simplify the use of Redis, Mysql, Mongodb
Install
Using npm:
$ npm install core-installer
##1 Using Redis
1.1 Redis initialization
const {RedisInstaller} = require('core-installer');
const TARGET={};
//1. Single instance configuration
let config={
// url:'redis://127.0.0.1:6379',
host:'127.0.0.1',
port:6379
}
const installer = new RedisInstaller(config,TARGET,false,true);
await installer. load();
//2. Multi-instance configuration
let config={
APP1: {
// url:'redis://127.0.0.1:6379',
host:'127.0.0.1',
port:6379
},
APP2: {
host:'127.0.0.1',
port:6379
},
}
const installer = new RedisInstaller(config,TARGET,true,true);
await installer. load();
1.2 Redis usage
//1. Use in single mode
await TARGET.REDIS.SET('TEST:KEY','abc');
let result = await TARGET.REDIS.GET('TEST:KEY');
console. log(result);
//2, use in multi-instance mode
await TARGET.REDIS.APP1.SET('TEST:KEY:APP1','app1');
let result1 = await TARGET.REDIS.APP1.GET('TEST:KEY:APP1');
console.log(result1);
await TARGET.REDIS.APP2.SET('TEST:KEY:APP2','app2');
let result2 = await TARGET.REDIS.APP2.GET('TEST:KEY:APP2');
console.log(result2);
2 Using Mysql
2.1 Mysql initialization
const {MysqlInstaller} = require('core-installer');
const TARGET={};
//1. Single instance configuration
let config={
host: "127.0.0.1",
port: 3306,
user: "root",
password: "root12345",
database: "test"
}
const installer = new MysqlInstaller(config,TARGET,false,true);
await installer. load();
//2. Multi-instance configuration
let config={
APP1: {
host: "127.0.0.1",
port: 3306,
user: "root",
password: "root12345",
database: "test"
},
APP2: {
host: "127.0.0.1",
port: 3306,
user: "root",
password: "root12345",
database: "test"
},
}
const installer = new MysqlInstaller(config,TARGET,true,true);
await installer. load();
2.2 Mysql use
//1. Use in single mode
let result = await TARGET.SQL('select * from test',[]);
console. log(result);
//2, use in multi-instance mode
let result1 = await TARGET.SQL.APP1('select * from test',[]);
console.log(result1);
let result2 = await TARGET.SQL.APP2('select * from test',[]);
console.log(result2);
1.2.0
12 months ago
1.1.9
1 year ago
1.1.8
1 year ago
1.1.7
1 year ago
1.1.6
1 year ago
1.1.5
1 year ago
1.1.4
1 year ago
1.1.3
1 year ago
1.1.2
1 year ago
1.1.1
1 year ago
1.1.0
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago