💽
Storage
What's a webapp without a database. Mu comes with built in storage so you can build rich apps rapidly.
To add storage to your application, you simply need to call
mu.storage
with the name of entity you would like to create. This will not create the database, it will simply provide the methods needed to get started.const todos = mu.storage('todos')
Once called you will then be able to use this to store data within your app.
const todos = mu.storage('todos')
async function createTodo() {
const todo = await todos.create({
todo: 'Create awesome app on Mu',
completed: true,
})
console.log(todo)
}
createTodo()
To create, update or delete any items in our storage will require the user is logged in.
Once you have items in your database, you are then able to fetch these with
mu.find
.const todos = mu.storage('todos')
async function listTodos() {
const todos = await todos.find()
console.log(todos)
}
listTodos()
By default all reads are public. This means they are not locked to the logged in user, this is good for apps where data is not unique to the user but if you would like to make data private please see permissions.
(Coming soon)
(Coming soon)
Last modified 1mo ago