w-serv-orm
v1.0.12
Published
An operator for orm in server.
Downloads
22
Maintainers
Readme
w-serv-orm
An operator for orm in server.
Documentation
To view documentation or get support, visit docs.
Installation
Using npm(ES6 module):
Note:
w-serv-orm
is mainly dependent onlodash-es
andwsemi
.
npm i w-serv-orm
Example for server:
Link: [dev source code]
import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM
import ds from './schema/index.mjs' //先行建置schema
import WServOrm from './src/WServOrm.mjs'
//st
let st = {
dbUsername: 'username',
dbPassword: 'password',
dbName: 'wservorm',
dbIP: 'localhost',
dbPort: 27017,
}
//url, db
let url = `mongodb://${st.dbUsername}:${st.dbPassword}@${st.dbIP}:${st.dbPort}`
let db = st.dbName
//WServOrm
let opt = {
getUserById: null,
bCheckUser: false,
bExcludeWhenNotAdmin: false,
}
let r = WServOrm(ds, WOrm, url, db, opt)
console.log(r) //回傳server用orm相關函數
// => {
// backup: [AsyncFunction: backup],
// recover: [AsyncFunction: recover],
// woItems: {
// tests: EventEmitter {
// _events: [Object: null prototype] {},
// _eventsCount: 0,
// _maxListeners: undefined,
// select: [AsyncFunction: select],
// insert: [AsyncFunction: insert],
// save: [AsyncFunction: save],
// del: [AsyncFunction: del],
// delAll: [AsyncFunction: delAll],
// selectGfs: [AsyncFunction: selectGfs],
// insertGfs: [AsyncFunction: insertGfs],
// delGfs: [AsyncFunction: delGfs],
// delAllGfs: [AsyncFunction: delAllGfs],
// [Symbol(kCapture)]: false
// }
// },
// addFunCheck: [Function: addFunCheck],
// addFunPreProcessing: [Function: addFunPreProcessing],
// addFunPostProcessing: [Function: addFunPostProcessing],
// procOrm: [AsyncFunction: procOrm]
// }