Quick Start
A brief guide to get you started with our library, covering setup and usage examples.
Installation
NPM:
Or Yarn:
Or PNPM:
Getting Started
To create a connection instance, you can use any database client of your choice and pass it to the createDatabase
function.
Alternatively, you can utilize the built-in createClient
function to simplify the process.
Defining Schemas and connecting to the database
Use the createSchema function to define the structure of your model. Specify the fields and their types, using the available types and modifiers.
Create a database instance using any client you deem fit and drop it into the createDatabase function
Or you can use the built-in createClient function.
Then you pass your schemas to the second arguement
Inserting Documents
You can insert new documents into your collection using the insert method. Ensure that the data conforms to the defined schema.
Example: Inserting a new user
Querying Documents
Retrieve documents from your collection using the find or findOne methods.
Example: Querying all users
Updating Documents
Update documents in your collection using the update method. You can update a single document or multiple documents based on a filter.
Example: Updating a single user's email
Example: Updating multiple users' isVerified field
Note: The update method returns the number of documents updated.
Conclusion
That's the end of our quick start. As you continue building your application, you may want to explore more advanced features like:
- Detailed connection setup
- Schema Types and Type modifiers for data validation
- Relations between collections
- Populations
- Transactions and atomic operations
Check out the rest of the documentation to learn more about these topics and other features available.