A Mongoose-like ODM built in TypeScript with YAML storage.
Familiar API. Zero infrastructure. Instant setup.
npm install mongoose-lite-js
import mongooseLite from "mongoose-lite-js";
mongooseLite.connect("./data");
const UserSchema = mongooseLite.Schema({
username: { type: String, required: true },
isActive: { type: Boolean, default: true },
role: { type: String, enum: ["tester", "dev"] },
});
const User = mongooseLite.model("User", UserSchema);
await User.create({ username: "Alex", role: "tester" });
const users = await User.find({});
console.log(users);
Familiar Mongoose patterns without the infrastructure overhead. Build prototypes, CLI tools, and lightweight apps with confidence.
Create documents with create() and save() — just like Mongoose.
Find documents with flexible filtering, single lookups, and ID-based retrieval.
Update single or multiple documents with a rich set of update operations.
Remove documents by filter, ID, or the first match — clean and predictable.
Count documents and check existence without loading full records.
Define structure, required fields, enums, min/max, defaults and more — all enforced.
From your application code to YAML persistence — every step is clear, validated, and predictable.
Your JS/TS application imports and uses the library
Initialize storage directory
mongooseLite.connect("./data")
Define structure & validation rules
type, required, enum, default
Create model bound to collection
mongooseLite.model("User", schema)
Perform create, read, update, delete through the Model API
Schema rules enforced before persistence
Defaults applied, updates processed, filters matched
Persisted as human-readable .yaml files via js-yaml
Install the package, connect to a directory, define your schema, and start querying.
npm install mongoose-lite-js
import mongooseLite from "mongoose-lite-js";
mongooseLite.connect("./data");
Data is persisted as YAML files inside the connected directory.
const UserSchema = mongooseLite.Schema({
username: { type: String, required: true },
isActive: { type: Boolean, default: true },
role: { type: String, enum: ["tester", "developer"] },
experience: Number
});
const User = mongooseLite.model("User", UserSchema);
await User.create({ username: "Alex", role: "tester" });
const users = await User.find({});
console.log(users);
You can also use CommonJS import syntax:
const mongooseLite = require("mongoose-lite-js");
Define your data shape with powerful constraints — the same patterns you already know from Mongoose.
const ProductSchema = mongooseLite.Schema({
name: { type: String, required: true },
price: { type: Number, min: 0 },
tags: [String],
details: {
weight: Number,
manufacturer: String
}
});
All the methods you'd expect from Mongoose — battle-tested patterns, zero configuration.
Model.create(doc)
Create and persist a new document
doc.save()
Save the document instance to storage
Model.find(filter)
Find all matching documents
Model.findOne(filter)
Find the first matching document
Model.findById(id)
Find a document by its ID
Model.updateOne(filter, update)
Update the first matching document
Model.updateMany(filter, update)
Update all matching documents
Model.findByIdAndUpdate(id, update)
Find by ID and apply updates
Model.findOneAndUpdate(filter, update)
Find first match and update
Model.replaceOne(filter, doc)
Replace the first matching document entirely
Model.deleteOne(filter)
Delete the first matching document
Model.deleteMany(filter)
Delete all matching documents
Model.findByIdAndDelete(id)
Find by ID and delete
Model.findByIdAndRemove(id)
Alias for findByIdAndDelete
Model.findOneAndDelete(filter)
Find first match and delete
Model.findOneAndRemove(filter)
Alias for findOneAndDelete
Model.countDocuments(filter)
Return count of matching documents
Model.exists(filter)
Check if any document matches
mongooseLite.Schema(definition)
Define structure, validation rules, and defaults
mongooseLite.model(name, schema)
Create a model bound to a YAML collection
mongooseLite.connect(path)
Initialize YAML-based storage at the given path
The source code is split into focused modules — easy to understand, extend, and contribute to.