@rattus-orm/solidjs
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Rattus ORM

bundle size npm version (core)

Rattus ORM – Solid.js

Solid.js data provider and helpers for Rattus ORM

Contents

  1. SolidjsDataProvider;
  2. <RattusProvier /> component;
  3. Hooks: useRattusContext, useRepository.

Installation

Use your favorite package manager. For example, yarn:

yarn add @rattus-orm/core @rattus-orm/solidjs

Basic usage

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>
  )
}

Documentation

For detailed docs please read documentation website.

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, and the process for submitting pull requests.

Package Sidebar

Install

npm i @rattus-orm/solidjs

Weekly Downloads

13

Version

0.1.0

License

MIT

Unpacked Size

139 kB

Total Files

6

Last publish

Collaborators

  • lyohaplotinka