Skip to content

Commit

Permalink
indexer: rename pgTable to pgIndexerTable (#110)
Browse files Browse the repository at this point in the history
This enables developers to use plain pgTable and pgIndexerTable in the
same schema file.
  • Loading branch information
jaipaljadeja authored Oct 30, 2024
2 parents 25fe12b + ec7cd32 commit 0912ce5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "indexer: rename pgTable to pgIndexerTable",
"packageName": "@apibara/indexer",
"email": "[email protected]",
"dependentChangeType": "patch"
}
4 changes: 2 additions & 2 deletions examples/starknet-indexer/src/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { defineIndexer, useSink } from "@apibara/indexer";
import {
drizzle as drizzleSink,
pgTable,
pgIndexerTable,
} from "@apibara/indexer/sinks/drizzle";
import { StarknetStream } from "@apibara/starknet";
import consola from "consola";
import { bigint } from "drizzle-orm/pg-core";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

const headers = pgTable("headers", {
const headers = pgIndexerTable("headers", {
number: bigint("number", { mode: "bigint" }),
});

Expand Down
4 changes: 2 additions & 2 deletions packages/indexer/src/sinks/drizzle/drizzle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { generateMockMessages } from "../../testing";
import { getMockIndexer } from "../../testing/indexer";
import type { Int8Range } from "./Int8Range";
import { drizzle as drizzleSink } from "./drizzle";
import { getDrizzleCursor, pgTable } from "./utils";
import { getDrizzleCursor, pgIndexerTable } from "./utils";

const testTable = pgTable("test_table", {
const testTable = pgIndexerTable("test_table", {
id: serial("id").primaryKey(),
data: text("data"),
});
Expand Down
8 changes: 6 additions & 2 deletions packages/indexer/src/sinks/drizzle/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type CursorColumnBuilder = NotNull<
>;

// Redefining the type of `pgTable` to include the `_cursor` column.
export type PgTableWithCursorFn<
export type PgIndexerTableWithCursorFn<
TSchema extends string | undefined = undefined,
> = <
TTableName extends string,
Expand Down Expand Up @@ -66,7 +66,11 @@ export type PgInsertValue<TTable extends PgTable> = Omit<
"_cursor"
>;

export const pgTable: PgTableWithCursorFn = (name, columns, extraConfig?) => {
export const pgIndexerTable: PgIndexerTableWithCursorFn = (
name,
columns,
extraConfig?,
) => {
return drizzlePgTable(
name,
{
Expand Down

0 comments on commit 0912ce5

Please sign in to comment.