-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store-sync,store-indexer): schemaless indexer (#1965)
- Loading branch information
Showing
51 changed files
with
1,124 additions
and
2,050 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
"@latticexyz/common": minor | ||
--- | ||
|
||
Added `unique` and `groupBy` array helpers to `@latticexyz/common/utils`. | ||
|
||
```ts | ||
import { unique } from "@latticexyz/common/utils"; | ||
|
||
unique([1, 2, 1, 4, 3, 2]); | ||
// [1, 2, 4, 3] | ||
``` | ||
|
||
```ts | ||
import { groupBy } from "@latticexyz/common/utils"; | ||
|
||
const records = [ | ||
{ type: "cat", name: "Bob" }, | ||
{ type: "cat", name: "Spot" }, | ||
{ type: "dog", name: "Rover" }, | ||
]; | ||
Object.fromEntries(groupBy(records, (record) => record.type)); | ||
// { | ||
// "cat": [{ type: "cat", name: "Bob" }, { type: "cat", name: "Spot" }], | ||
// "dog: [{ type: "dog", name: "Rover" }] | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@latticexyz/store-indexer": minor | ||
--- | ||
|
||
The `findAll` method is now considered deprecated in favor of a new `getLogs` method. This is only implemented in the Postgres indexer for now, with SQLite coming soon. The new `getLogs` method will be an easier and more robust data source to hydrate the client and other indexers and will allow us to add streaming updates from the indexer in the near future. | ||
|
||
For backwards compatibility, `findAll` is now implemented on top of `getLogs`, with record key/value decoding done in memory at request time. This may not scale for large databases, so use wisely. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@latticexyz/store-sync": major | ||
--- | ||
|
||
`syncToPostgres` from `@latticexyz/store-sync/postgres` now uses a single table to store all records in their bytes form (`staticData`, `encodedLengths`, and `dynamicData`), more closely mirroring onchain state and enabling more scalability and stability for automatic indexing of many worlds. | ||
|
||
The previous behavior, where schemaful SQL tables are created and populated for each MUD table, has been moved to a separate `@latticexyz/store-sync/postgres-decoded` export bundle. This approach is considered less stable and is intended to be used for analytics purposes rather than hydrating clients. Some previous metadata columns on these tables have been removed in favor of the bytes records table as the source of truth for onchain state. | ||
|
||
This overhaul is considered breaking and we recommend starting a fresh database when syncing with either of these strategies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.