Skip to main content

πŸš€ Welcome to Cascade!

Part of the Warlock.js Full-Stack Framework

Hey there! πŸ‘‹ Ready to supercharge your Node.js apps with a delightful MongoDB experience? Cascade is your new best friend for all things database: easy, powerful, and fun to use!

πŸ€” Why Cascade?​

There are a few MongoDB tools out there (like Mongoose and Prisma), but Cascade is:

  • 🧩 Simple & Intuitive: Just a thin, friendly wrapper around the MongoDB driver.
  • πŸ”Œ Multi-connection & Multi-database: Connect to as many databases as you want, easily.
  • πŸ§™β€β™‚οΈ Full-featured Models: Models are first-class citizens, with tons of utilities.
  • πŸ—οΈ Powerful Aggregation: Build complex queries with a breeze.
  • ⚑ Events-Driven: Listen and react to database events (before/after create, update, delete, etc.).
  • πŸ—ƒοΈ Embedded Documents: Nest documents inside each other, no sweat.
  • πŸ”„ Syncing Models: Auto-update related data when things changeβ€”see below!
  • πŸ—‘οΈ Recycle Bin: Soft-delete with a trash collection.
  • πŸ› οΈ Migration System: Evolve your schema with confidence.
  • πŸ§™β€β™‚οΈ Auto-increment & Random IDs: Choose your own adventure for primary keys.
  • πŸ§ͺ Data Casting: Type-safe, custom, and automatic casting.
  • πŸ“¦ Pagination, Output Formatting, and More!
Did you know?

Syncing Models is a rare and powerful featureβ€”almost no other MongoDB ORM or framework offers it! With Cascade, you can automatically keep related documents in sync. For example, when you update a user's profile, all related posts or comments can be updated too, automagically ✨. Learn more about syncing models β†’

And that's just the start! Cascade is designed to be delightful for both beginners and pros.

πŸ‘€ Quick Peek: Defining a Model​

src/models/user.ts
import { Model } from "@warlock.js/cascade";

export class User extends Model {
/**
* The collection name (required)
*/
public static collection = "users";
}

✨ Creating a User (So Easy!)​

src/controllers/users.ts
import { User } from "src/models/user";

export async function createUser() {
const user = await User.create({
name: "Hasan Zohdy",
email: "hassanzohdy@gmail.com",
});

console.log(user.data);
}

Outputs:

{
"id": 1231412,
"_id": "fagtrw43qwedasjoijwq",
"name": "Hasan Zohdy",
"email": "hassanzohdy@gmail.com",
"createdAt": "2023-06-01 00:00:00",
"updatedAt": "2023-06-01 00:00:00"
}

🌟 What's Next?​

Happy coding! πŸŽ‰