Registry / database / w-serv-orm

w-serv-orm

JSON →
library1.0.38jsnpmunverified

An operator for ORM in server environments, providing a wrapper around ORM libraries like w-orm-mongodb or w-orm-lowdb. Version 1.0.38 is the latest stable release. It offers functions such as backup, recover, and CRUD operations (select, insert, save, delete) for multiple data sources, with additional hooks for custom checks and preprocessing. Key differentiators include pluggable ORM backends (MongoDB, LowDB) and built-in authentication/user check support with configurable exclusions.

npm install w-serv-orm
INSTALL
IMPORT
SIG · W-SERV-ORM
W
w-serv-orm
databasejavascriptv1.0.38
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WServOrm
import WServOrm from 'w-serv-orm'
const WServOrm = require('w-serv-orm')
Package is ESM-only; CommonJS require will fail.
backup
import { backup } from 'w-serv-orm'
import { backup } from 'w-serv-orm/src/WServOrm.mjs'
Named export is available at package root.
woItems.tests
import { woItems } from 'w-serv-orm'; const tests = woItems.tests;
import { tests } from 'w-serv-orm'
CRUD objects are nested under woItems.

Initializes WServOrm with lowdb backend and inserts a test record.

import WOrm from 'w-orm-lowdb/src/WOrmLowdb.mjs'; import ds from './schema/index.mjs'; import WServOrm from 'w-serv-orm'; let url = './db.json'; let db = 'worm'; let opt = { getUserById: null, useCheckUser: false, useExcludeWhenNotAdmin: false, }; let r = WServOrm(ds, WOrm, url, db, opt); console.log(Object.keys(r)); // ['backup','recover','woItems','addFunCheck','addFunPreProcessing','addFunPostProcessing','procOrm'] let tests = r.woItems.tests; tests.insert({name:'test'}).then(console.log);
Debug
Known issues
gotchaThe package expects an ORM instance (WOrm) with a specific interface; using an incompatible ORM may cause runtime errors.
fix
Ensure the imported WOrm has methods like connect, select, insert, save, del.
affects: >=1.0.0
deprecatedAs of v1.0.0, CommonJS require is not supported (ESM-only).
fix
Use dynamic import() or switch to ESM.
affects: >=1.0.0
gotchaThe 'opt.getUserById' parameter must be null or a function that returns a user object for authentication features to work.
fix
Provide a function or set null to skip user checks.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'select')
WOrm instance not properly initialized or missing required methods.
fix
Ensure WOrm is imported from a compatible package (e.g., w-orm-lowdb) and that the schema is correctly defined.
Module not found: Error: Can't resolve 'w-orm-mongodb'
Trying to use MongoDB backend without installing the dependency.
fix
Run 'npm install w-orm-mongodb' or switch to lowdb backend.
TypeError: WServOrm is not a function
Using CommonJS require on ESM-only package.
fix
Switch to ES module import syntax: import WServOrm from 'w-serv-orm'
Upgrade
Version history
1.0.38latest on npm
Audit
Dependencies
w-orm-mongodboptionalOptional ORM backend for MongoDB
w-orm-lowdboptionalOptional ORM backend for LowDB (JSON file)
Agent activity
13 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources
w-serv-orm — npm install w-serv-orm · libregistry