Registry / database / wetland

wetland

JSON →
library5.1.2jsnpmunverified

Wetland is a modern object-relational mapper (ORM) for Node.js, inspired by the JPA specification (Hibernate/Doctrine). Version 5.1.2 is the latest stable release. It provides a full-featured ORM with unit of work, migrations, transactions, query builder, entity manager, repositories, and deep joins. Built on top of Knex, it supports MySQL, SQLite, and PostgreSQL. Wetland's key differentiators include JPA-like structure, optimized state management, and recipe-based hydration. Typings are included for TypeScript users. The package is actively maintained.

npm install wetland
INSTALL
IMPORT
SIG · WETLAND
W
wetland
databasejavascriptv5.1.2
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.

Wetland
import { Wetland } from 'wetland'
const Wetland = require('wetland');
Default export not available. Must use named import. For CommonJS: const { Wetland } = require('wetland'). ESM since v5.
EntityManager
import { EntityManager } from 'wetland'
Available as named export. Not typically imported directly; obtained via wetland.getManager().
Migrator
import { Migrator } from 'wetland'
Available as named export. Not typically imported directly; obtained via wetland.getMigrator().

Shows instantiation of Wetland, creating tables via migrator, and querying with joins.

import { Wetland } from 'wetland'; import { Foo } from './entity/foo'; import { Bar } from './entity/bar'; const wetland = new Wetland({ stores: { myStore: { client: 'mysql', connection: { user: 'root', database: 'testdatabase', password: process.env.DB_PASSWORD ?? '' } } }, entities: [Foo, Bar] }); // Create tables (async) const migrator = wetland.getMigrator().create(); migrator.apply().then(() => { console.log('Tables created'); }); // Get a manager scope (per request) const manager = wetland.getManager(); const repository = manager.getRepository(Foo); repository.find({ name: 'cake' }, { joins: ['candles', 'baker'] }).then(results => { console.log(results); });
Debug
Known issues
gotchaWhen using sqlite3, foreign keys are disabled because sqlite does not support ALTER TABLE for foreign keys.
fix
Use a different database like MySQL or PostgreSQL for foreign key support.
affects: >=1.0.0
breakingWetland v5 changed from CommonJS to ESM. require() no longer works for default import; must use named import.
fix
Use import { Wetland } from 'wetland' instead of const Wetland = require('wetland'). For CommonJS projects, use dynamic import or update to ESM.
affects: >=5.0.0
deprecatedWetland CLI is now a separate package: wetland-cli. Installing wetland does not include CLI.
fix
Install wetland-cli globally: npm i -g wetland-cli
affects: >=5.0.0
gotchaEntity classes must have a static setMapping method. Forgetting it leads to mapping errors.
fix
Add static setMapping(mapping) { ... } to entity classes.
affects: >=1.0.0
gotchaEntities must be registered in the Wetland constructor. Omitting them causes runtime errors.
fix
Pass entities array in Wetland configuration.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'wetland'
Wetland not installed in project.
fix
Run: npm install wetland
TypeError: wetland.getManager is not a function
Using default import incorrectly; Wetland class is a named export.
fix
Use import { Wetland } from 'wetland' instead of import Wetland from 'wetland'.
Error: Mapping is not defined. Entity must have setMapping method.
Entity class missing static setMapping method or not properly exported.
fix
Add static setMapping(mapping) { ... } to entity class.
Error: Cannot read property 'apply' of undefined
getMigrator().create() returned undefined, likely due to missing or incorrect store configuration.
fix
Ensure store configuration has correct client and connection parameters.
Error: Knex: require() of ES Module not supported
Knex version incompatibility with CommonJS project.
fix
Use Wetland v4 or ensure your project is ESM. Alternatively, use dynamic import.
Upgrade
Version history
5.1.2latest on npm
Audit
Dependencies
knexrequiredWetland uses Knex as the underlying SQL query builder and dialect connector.
mysqloptionalRequired when using MySQL as the database client.
sqlite3optionalRequired when using SQLite as the database client.
pgoptionalRequired when using PostgreSQL as the database client.
Agent activity
22 hits · last 30 days
node
18
Meta
2
OpenAI (training)
1
Resources
wetland — npm install wetland · libregistry