You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-24Lines changed: 59 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Homebase React
2
2
3
-
> The graph database for simple React state management
3
+
> The graph database for delightful React state management
4
4
5
5
## Installation
6
6
@@ -24,38 +24,51 @@ You can clone and run our React code examples [here](https://github.com/homebase
24
24
25
25
## Purpose
26
26
27
-
We want software to be [local-first](https://news.ycombinator.com/item?id=21581444). That means we need to make it more convenient to work with complex data on clients.
27
+
We want data to be a first class citizen on the client. We love relational databases in our servers and we want that same experience in our React apps. In other words, we want our applications to be [local-first](https://news.ycombinator.com/item?id=21581444). That means we need to make it easier to work with complex data on clients.
28
28
29
-
Homebase React lets you plug a relational database into your React app.
29
+
Homebase React lets you plug a relational database into your React app with 3 lines of code. In fact it's the same database that powers Roam Research and many other ClojureScript applications, but with an API that's familiar to React and JS developers.
30
30
31
31
- Replace Redux with something simpler and more declarative
32
32
- Gain all the benefits of relational data like a single source of truth
33
33
- Query your database with a convenient JSON query syntax
34
-
- Query your database with datalog if you need more power
34
+
- Query your database with Clojure style datalog if you need more power
35
35
- Traverse your data graph like it's one big JSON object
36
+
- Stop spending time wiring up custom datatypes, reducers, caches and other bespoke state mumbo jumbo
37
+
- It's just data
36
38
37
-
It is immediately more intuitive than a denormalized JSON store, and over time it will get better as we add more local-first features to it.
39
+
We think that Homebase React is immediately more intuitive than any denormalized JSON store, and over time it will get better as we eliminate all the tedious aspects of manipulating data on clients.
38
40
39
41
## API Overview
40
42
41
43
### `HomebaseProvider`
42
44
45
+
The HomebaseProvider wraps your React app and makes a relational database accessible to all of your components. Configure it with `schema` and `initialData`.
Entities are the building blocks of the Homebase data model. They are like JSON objects with bonus features. In particular **you can traverse arbitrarily deep relationship without actually denormalizing and nesting your data**.
74
85
75
-
// Get attributes off an entity
76
-
todo.get('name') // => 'Make it'
86
+
```js
87
+
// You can get an entity by its id and get attributes off of it.
88
+
const [todo] =useEntity(2)
77
89
todo.get('id') // => 2
90
+
todo.get('name') // => 'Make it'
78
91
79
-
// You can also get an entity by its id
80
-
const [sameTodo] =useEntity(2)
92
+
// Entities with unique attributes can also be retrieved by those attributes.
Transactions let you create, update and delete multiple entities simultaneously. All changes will reactively update any components that depend on the changed data.
103
+
88
104
```js
89
105
consttransact=useTransact()
90
106
91
-
// A transaction is an array of nested objects
107
+
// A transaction is an array of nested objects and or arrays.
// To remove an attribute you have to explicitly set it to null.
123
+
transact([{ project: { id:1, name:null } }])
124
+
125
+
// To delete an entire entity use retractEntity and its id
98
126
transact([['retractEntity', 1]])
99
127
```
100
128
101
129
### `useQuery`
102
130
131
+
Use queries to return an array of entities that meet a given criteria. Our query API is powered by datalog, but exposed as JSON similar to a JS SQL driver or Mongo DB. Datalog is similar to SQL and is incredibly powerful. However only a subset of features are currently available in JSON.
132
+
133
+
We are very interested in what features the community wants, and will prioritize based on feedback. In the meantime you can further filter results with JS `filter()` and `sort()`.
0 commit comments