w-serv-orm

1.0.10 • Public • Published

w-serv-orm

An operator for orm in server.

language npm version license gzip file size npm download npm download jsdelivr download

Documentation

To view documentation or get support, visit docs.

Installation

Using npm(ES6 module):

Note: w-serv-orm is mainly dependent on lodash-es and wsemi.

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]
// }

Package Sidebar

Install

npm i w-serv-orm

Weekly Downloads

4

Version

1.0.10

License

MIT

Unpacked Size

1.35 MB

Total Files

62

Last publish

Collaborators

  • semisphere