Build a simple Todo app with Modelence
In this tutorial, we’ll build a complete Todo app using Modelence. You’ll learn how to:
This tutorial assumes you’ve already created a Modelence project and completed the setup. If you haven’t done so, please complete those steps first.
Stores in Modelence are MongoDB collections with built-in TypeScript support, schema and helper methods. They help you to:
The recommended approach in Modelence is to group code by modules/domains into separate directories. For our Todo app, create an src/server/todo
directory and add a db.ts
file:
Once defined, you can use your Store object to perform operations on your collection:
Stores provide a comprehensive set of methods for working with MongoDB documents, including finding, inserting, updating, and deleting records. All methods are fully typed with TypeScript.
See the Store API Reference for a complete list of available methods and their usage.
Stores automatically handle MongoDB connection management, collection provisioning and index creation. Just define your Store and start using it - Modelence takes care of the rest.
Modules are the core building blocks of a Modelence application. They help you organize your application’s functionality into cohesive units that can contain queries, mutations, stores, cron jobs and configurations.
Create a new file at src/server/todo/index.ts
:
Now, add the Module to your main server file at src/server/app.ts
:
As soon as your app starts, Modelence will:
dbTodos
store in MongoDBModelence is frontend-agnostic, so you are free to use any routing library you like. We will use React Router for this example, which is what’s included in the default Modelence starter.
Edit src/client/routes.ts
to add a new route for our todos:
Create a new component at src/client/TodosPage.tsx
:
Want to see the full working code? Check it out on GitHub, along with other examples:
See the complete source code for this tutorial on GitHub, including all files and additional features.
Build a simple Todo app with Modelence
In this tutorial, we’ll build a complete Todo app using Modelence. You’ll learn how to:
This tutorial assumes you’ve already created a Modelence project and completed the setup. If you haven’t done so, please complete those steps first.
Stores in Modelence are MongoDB collections with built-in TypeScript support, schema and helper methods. They help you to:
The recommended approach in Modelence is to group code by modules/domains into separate directories. For our Todo app, create an src/server/todo
directory and add a db.ts
file:
Once defined, you can use your Store object to perform operations on your collection:
Stores provide a comprehensive set of methods for working with MongoDB documents, including finding, inserting, updating, and deleting records. All methods are fully typed with TypeScript.
See the Store API Reference for a complete list of available methods and their usage.
Stores automatically handle MongoDB connection management, collection provisioning and index creation. Just define your Store and start using it - Modelence takes care of the rest.
Modules are the core building blocks of a Modelence application. They help you organize your application’s functionality into cohesive units that can contain queries, mutations, stores, cron jobs and configurations.
Create a new file at src/server/todo/index.ts
:
Now, add the Module to your main server file at src/server/app.ts
:
As soon as your app starts, Modelence will:
dbTodos
store in MongoDBModelence is frontend-agnostic, so you are free to use any routing library you like. We will use React Router for this example, which is what’s included in the default Modelence starter.
Edit src/client/routes.ts
to add a new route for our todos:
Create a new component at src/client/TodosPage.tsx
:
Want to see the full working code? Check it out on GitHub, along with other examples:
See the complete source code for this tutorial on GitHub, including all files and additional features.