Svelte bindings for Rattus ORM
-
<RattusProvier />
component; - Hooks:
useRattusContext
,useRepository
.
Use your favorite package manager. For example, yarn:
yarn add @rattus-orm/core @rattus-orm/svelte
<script>
import { RattusProvider } from '@rattus-orm/svelte'
</script>
<RattusProvider>
<!-- your components -->
</RattusProvider>
export class User extends Model {
public static entity = 'user'
@Uid()
public id: string
@Str()
public email: string
}
<script>
import { useRepository } from "@rattus-orm/svelte";
import { User } from "./models/User";
const userRepo = useRepository(User)
const user = userRepo.find('1')
setTimeout(() => {
userRepo.save({ id: '1', email: 'test@test.com' })
}, 1000)
</script>
<div>
{#if $user}
id: {$user.id}<br/>
email: {$user.email}
{/if}
</div>
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.