Home / File/ singlestore.schema.ts — drizzle-orm Source File

singlestore.schema.ts — drizzle-orm Source File

Architecture documentation for singlestore.schema.ts, a typescript file in the drizzle-orm codebase. 2 imports, 0 dependents.

File typescript DrizzleORM RelationalQuery 2 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  a47d293e_969b_f3ef_0270_527225b9cd39["singlestore.schema.ts"]
  b4539857_26bc_b042_0719_5e529c80f1b4["singlestore-core"]
  a47d293e_969b_f3ef_0270_527225b9cd39 --> b4539857_26bc_b042_0719_5e529c80f1b4
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  a47d293e_969b_f3ef_0270_527225b9cd39 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  style a47d293e_969b_f3ef_0270_527225b9cd39 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { bigint, boolean, primaryKey, serial, singlestoreTable, text, timestamp } from 'drizzle-orm/singlestore-core';

import { relations } from 'drizzle-orm';

export const usersTable = singlestoreTable('users', {
	id: serial('id').primaryKey(),
	name: text('name').notNull(),
	verified: boolean('verified').notNull().default(false),
	invitedBy: bigint('invited_by', { mode: 'number' }),
});
export const usersConfig = relations(usersTable, ({ one, many }) => ({
	invitee: one(usersTable, {
		fields: [usersTable.invitedBy],
		references: [usersTable.id],
	}),
	usersToGroups: many(usersToGroupsTable),
	posts: many(postsTable),
	comments: many(commentsTable),
}));

export const groupsTable = singlestoreTable('groups', {
	id: serial('id').primaryKey(),
	name: text('name').notNull(),
	description: text('description'),
});
export const groupsConfig = relations(groupsTable, ({ many }) => ({
	usersToGroups: many(usersToGroupsTable),
}));

export const usersToGroupsTable = singlestoreTable(
	'users_to_groups',
	{
		id: serial('id').primaryKey(),
		userId: bigint('user_id', { mode: 'number' }).notNull(),
		groupId: bigint('group_id', { mode: 'number' }).notNull(),
	},
	(t) => ({
		pk: primaryKey(t.userId, t.groupId),
	}),
);
export const usersToGroupsConfig = relations(usersToGroupsTable, ({ one }) => ({
	group: one(groupsTable, {
		fields: [usersToGroupsTable.groupId],
		references: [groupsTable.id],
	}),
	user: one(usersTable, {
		fields: [usersToGroupsTable.userId],
		references: [usersTable.id],
	}),
}));

export const postsTable = singlestoreTable('posts', {
	id: serial('id').primaryKey(),
	content: text('content').notNull(),
	ownerId: bigint('owner_id', { mode: 'number' }),
	createdAt: timestamp('created_at')
		.notNull()
		.defaultNow(),
});
export const postsConfig = relations(postsTable, ({ one, many }) => ({
	author: one(usersTable, {
		fields: [postsTable.ownerId],
		references: [usersTable.id],
	}),
	comments: many(commentsTable),
}));

export const commentsTable = singlestoreTable('comments', {
	id: serial('id').primaryKey(),
	content: text('content').notNull(),
	creator: bigint('creator', { mode: 'number' }),
	postId: bigint('post_id', { mode: 'number' }),
	createdAt: timestamp('created_at')
		.notNull()
		.defaultNow(),
});
export const commentsConfig = relations(commentsTable, ({ one, many }) => ({
	post: one(postsTable, {
		fields: [commentsTable.postId],
		references: [postsTable.id],
	}),
	author: one(usersTable, {
		fields: [commentsTable.creator],
		references: [usersTable.id],
	}),
	likes: many(commentLikesTable),
}));

export const commentLikesTable = singlestoreTable('comment_likes', {
	id: serial('id').primaryKey(),
	creator: bigint('creator', { mode: 'number' }),
	commentId: bigint('comment_id', { mode: 'number' }),
	createdAt: timestamp('created_at')
		.notNull()
		.defaultNow(),
});
export const commentLikesConfig = relations(commentLikesTable, ({ one }) => ({
	comment: one(commentsTable, {
		fields: [commentLikesTable.commentId],
		references: [commentsTable.id],
	}),
	author: one(usersTable, {
		fields: [commentLikesTable.creator],
		references: [usersTable.id],
	}),
}));

Domain

Subdomains

Dependencies

  • drizzle-orm
  • singlestore-core

Frequently Asked Questions

What does singlestore.schema.ts do?
singlestore.schema.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, RelationalQuery subdomain.
What functions are defined in singlestore.schema.ts?
singlestore.schema.ts defines 7 function(s): commentLikesConfig, commentsConfig, groupsConfig, postsConfig, usersConfig, usersToGroupsConfig, usersToGroupsTable.
What does singlestore.schema.ts depend on?
singlestore.schema.ts imports 2 module(s): drizzle-orm, singlestore-core.
Where is singlestore.schema.ts in the architecture?
singlestore.schema.ts is located at integration-tests/tests/relational/singlestore.schema.ts (domain: DrizzleORM, subdomain: RelationalQuery, directory: integration-tests/tests/relational).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free