Solid.js data provider and helpers for Rattus ORM
- SolidjsDataProvider;
-
<RattusProvier />
component; - Hooks:
useRattusContext
,useRepository
.
Use your favorite package manager. For example, yarn:
yarn add @rattus-orm/core @rattus-orm/solidjs
import { render } from 'solid-js/web'
import './index.css'
import App from './App'
import { RattusProvider } from '@rattus-orm/solidjs'
const root = document.getElementById('root')
render(() => (
<RattusProvider>
<App />
</RattusProvider>
), root
)
export class User extends Model {
public static entity = 'user'
@Uid()
public id: string
@Str()
public email: string
}
import { createComputed, onMount } from 'solid-js'
import { useRepository } from "@rattus-orm/solidjs";
import { User } from "./models/User.ts";
function App() {
const { save, find } = useRepository(User)
const user = find('1')
onMount(() => {
save({ id: '1', email: 'test' })
})
return (
<div>
<p>{ user()?.email }</p>
<button type="button" onClick={() => save({ id: '1', email: 'updated@test.com' })}>Update email</button>
</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.