Registry / database / orm-weapp

orm-weapp

JSON →
library1.1.6jsnpmunverified

orm-weapp is an ORM framework for WeChat Mini Programs using Tencent CloudBase (TCB) and MongoDB. Current version 1.1.6, released under MIT license. It provides a Model layer abstraction over the cloud database, supporting schema validation, CRUD operations, and query building. Key differentiators: designed specifically for WeChat Mini Programs with cloud development, lightweight and minimal dependencies, uses a clean ActiveRecord-like pattern. Compared to alternatives like wx-server-sdk, it offers higher-level abstractions and validation.

npm install orm-weapp
INSTALL
IMPORT
SIG · ORM-WEAPP
O
orm-weapp
databasejavascriptv1.1.6
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.

Model
import { Model } from 'orm-weapp'
const Model = require('orm-weapp')
ESM-only; CommonJS require will not work.
default import
import orm from 'orm-weapp'
const orm = require('orm-weapp')
ESM default export; using require will fail.
types
import type { ModelSchema } from 'orm-weapp'
TypeScript type imports via ESM.

Shows defining a User model with schema, creating a record, and querying with a filter.

import { Model } from 'orm-weapp'; const User = new Model('users', { schema: { name: { type: String, required: true }, email: { type: String }, age: { type: Number } } }); async function main() { const newUser = await User.create({ name: 'Alice', email: 'alice@example.com', age: 30 }); console.log('Created:', newUser); const users = await User.find({ age: { $gte: 18 } }); console.log('Adult users:', users); } main().catch(console.error);
Debug
Known issues
breakingVersion 1.0.0 removed the legacy init() method. Use constructor options instead.
fix
Replace MyModel.init({...}) with new Model('name', {...})
affects: >=1.0.0
deprecatedThe static method Model.collection() is deprecated in v1.1.0; use Model.prototype.db directly.
fix
Use model.db instead of Model.collection()
affects: >=1.1.0
gotchaSchema validation does not work with nested objects before v1.2.0.
fix
Upgrade to >=1.2.0 or manually validate nested fields.
affects: <1.2.0
Errors
Common errors & fixes
Cannot find module 'orm-weapp'
Missing package installation or incorrect import path.
fix
Run npm install orm-weapp and ensure ESM import syntax.
TypeError: Model is not a constructor
Importing as default instead of named import or using require.
fix
Use import { Model } from 'orm-weapp'.
Schema field 'xxx' has invalid type
Type definition not supported; only String, Number, Boolean, Date, Object, Array are allowed.
fix
Use one of the supported types; do not use custom constructors.
Upgrade
Version history
1.1.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
orm-weapp — npm install orm-weapp · libregistry