0.0.13 • Published 3 months ago

@indiex/silo v0.0.13

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
3 months ago

Silo - The local datastore for React Native and Expo

Here is how to use but... don't use this right now

If you use it anyway and would like to leave some feedback then leave feedback here or DM me on X

import { FlatList, StyleSheet, Text, View } from 'react-native'
import { Type } from '@sinclair/typebox'
import {
  defineCollection,
  defineHierarchy,
  defineSchema,
  createStore,
} from '@indiex/silo'

const notes = defineCollection(
  Type.Object({
    content: Type.String(),
  })
)

const tasks = defineCollection(
  Type.Object({
    details: Type.String(),
  })
)

const schema = defineSchema({ notes, tasks })
const hierarchy = defineHierarchy(schema, {
  notes: {
    tasks: '*',
  },
})
const store = createStore(hierarchy)

export default function App() {
  const { docs: notes, queryKey } = store.useQuery(['notes'])

  // const { doc: note1 } = store.useDoc(['notes', 'note1'])

  // const addDoc = store.useAddDoc([queryKey])
  // const { id: noteId } = await addDoc(['notes'], {
  // content: 'This is a note',
  // })
  // const updateDoc = store.useUpdateDoc([queryKey])
  // await updateDoc(['notes', 'note1'], { content: 'task1' })

  // const removeDoc = store.useRemoveDoc([queryKey])
  // await removeDoc(['notes', 'note1'])

  // const setDoc = store.useSetDoc([queryKey])
  // await setDoc(['notes', 'note1'], {
  // content: 'This is a note',
  // })

  return (
    <View style={styles.container}>
      <FlatList
        keyExtractor={(_, index) => index.toString()}
        data={notes}
        renderItem={({ item }) => <Text>{item.content}</Text>}
      />
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
})

Inspiration was taken from Firebase and Deno KV

0.0.13

3 months ago

0.0.10

3 months ago

0.0.11

3 months ago

0.0.12

3 months ago

0.0.9

3 months ago

0.0.8

3 months ago

0.0.7

3 months ago

0.0.6

3 months ago

0.0.5

3 months ago

0.0.4

3 months ago

0.0.3

3 months ago

0.0.2

3 months ago

0.0.1

3 months ago