Vuex data provider and helpers for Rattus ORM
- VuexDataProvider;
- Composables:
useRattusContext
,useRepository
.
Use your favorite package manager. For example, yarn:
yarn add @rattus-orm/core @rattus-orm/vuex
import { createApp } from 'vue'
import { createStore } from 'vuex'
import { installRattusORM } from "@rattus-orm/vuex";
const store = createStore({
plugins: [installRattusORM()]
})
const app = createApp({ /* your root component */ })
app.use(store)
<template>
<p>{{ user.email }}</p>
<button type="button" @click="onClick">Update email</button>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { Model, Uid, Str } from '@rattus-orm/core'
import { useRepository } from '@rattus-orm/vuex'
class User extends Model {
public static entity = 'user'
@Uid()
public id: string
@Str()
public email: string
}
export default defineComponent({
setup() {
const { save, find } = useRepository(User)
save({ id: '1', email: 'test@test.com' })
const onClick = () => {
save({ id: '1', email: 'updated@test.com' })
}
const user = find('1')
return {
user,
onClick,
}
}
})
</script>
For detailed docs please read documentation website.
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, and the process for submitting pull requests.