OptimaDB is designed to be intuitive and easy to use—no need for hours of tutorials or complex setup. You can start querying your data in just a few lines of code.
1 - Insert sample users
Let's add some users to our database. This will allow us to demonstrate how to query and filter data. Note that when you insert a password, OptimaDB will automatically hash it for you.
typescript
1
2
3
4
5
6
7
8
9
10
11
2 - Get all users
Retrieve all users from the database. This returns an array of user objects.
typescript
1
2
3
3 - Get a user by email
You can fetch a single user by providing a filter. Here, we get the user with a specific email address.
typescript
1
2
4 - Get a user by password
To authenticate a user, you can query by password as well. OptimaDB automatically hashes passwords on insert and verifies them for you when you query with a password condition—just provide the plain password, and OptimaDB will handle the comparison securely.
typescript
1
2
5 - Get a user by email and password
You can also combine conditions, such as email and password. Again, password verification is automatic—just pass the plain password, and OptimaDB will check it against the stored hash.
typescript
1
2