biota
A simple database framework to start your next project in 30s with FaunaDB
Find the raw documentation here.
import { Biota } from "biota";
const db = new Biota({ secret: "<your-secret>" });
await db.foundation();
await db.collection("todos").scaffold();
await db.collection("todos").index({ field: "name", ngram: true });
let asUser = await db.user().register("my@email.com", "password", {
nickname: "Georgy",
});
await asUser.documents("todos").insert({ name: "Remember to star this project" });
await asUser.documents("todos").find({ name: { $ngram: "star" } });
Current status
Finishing up design and tests of the main API (400+ methods).
🙃 You're on preview release. Don't get scared though, the api is pretty stable but tests need to be added to be fool-proof. (Thus, as of yet, Biota isn't production ready)
❤️ Check the features and request the ones you would love to see in biota. (They arn't all listed yet!)
Found some errors? Let us know!
Getting Started
These instructions will take you through the few steps to get started playing with your Fauna database.
Prerequisites
You'll need to add biota
either as a global or local (project) dependency.
yarn add biota
npm i biota
Import
import { Biota } from "biota";
const { Biota } = require("biota");
Instance
There are two ways to instantiate Biota.
- You can use a
admin/server key
(or any secret key) as a paremeter.
const db = new Biota({ secret: "<your-secret>"})
await db.query( q.Create(...) )
- You can use the function
.login(id, password)
to log a user.
const db = new Biota()
const logged = await db.login("123", "super_password123")
const logged = await db.current.user.login("123", "super_password123")
await logged.query( q.Create(...) )
Api
Even though you can query
your database (same as you would do with the same fauna method query
), the main power of Biota lives in its extended api.
⏳ Patience: It's coming.. :)
Helpers
const { q, factory, Page } = require('biota')
q.If(..., true, false)
factory.database(ctx)(name).insert(options)
Running the tests
If you want to run the tests, you'll need to provide a FAUNA_KEY_TEST=<your-test-key>
in a .env
file.
:warning: Careful: At the moment tests covering everything yet. PR welcomed 😉
Built With
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning.
For the versions available, see the tags on this repository.
Authors
- Gabin Desserprit instigator
See also the list of contributors who participated in this project.
Join us :beers:
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
This lib wouldn't exist if I had not dug deep into Fauna FQL and got helped through the Fauna's slack community channel. In no order, I'ld like to thank, for their help and support, fauna's team (Brecht De Rooms, Ben Edwards, Marrony Neris, Leo Regnier, Summer, ,...) as well as other users like Eigil Sagafos 🙏