Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: include pre-defined database objects related to Neon Identity in drizzle-orm #3959

Closed
1 task done
pffigueiredo opened this issue Jan 16, 2025 · 1 comment
Closed
1 task done
Labels
enhancement New feature or request

Comments

@pffigueiredo
Copy link
Contributor

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Description

Neon is about to launch a feature (Neon Identity) that will include a couple of pre-defined database objects:

  • neon_identity schema
  • users_sync table

However, for consumers of Drizzle to easily relate this users data with their other DB objects, it would be very beneficial that they could simply import them, and not have to write them in their schema everytime.

EXAMPLE

import { neonUsersTable } from "drizzle-orm/neon";
import { relations } from "drizzle-orm";
import { bigint, boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core";

export const todos = pgTable("todos", {
  id: bigint("id", { mode: "bigint" })
    .primaryKey()
    .generatedByDefaultAsIdentity(),
  ownerId: text("owner_id"),
  task: text("task").notNull(),
  isComplete: boolean("is_complete").notNull().default(false),
  insertedAt: timestamp("inserted_at", { withTimezone: true })
    .defaultNow()
    .notNull(),
});

export const todosRelations = relations(todos, ({ one }) => ({
  owner: one(users, {
    fields: [todos.ownerId],
    references: [users.id],
  }),
}));

export const users = neonUsersTable();
@AndriiSherman
Copy link
Member

Available in [email protected]

Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants