feat: add isolated memory spaces
This commit is contained in:
@@ -13,12 +13,14 @@ export interface FactTopicJoinRow extends TopicRecord {
|
||||
|
||||
export async function findFactRowsForTopicId(
|
||||
executor: DatabaseExecutor,
|
||||
spaceId: string,
|
||||
topicId: string,
|
||||
): Promise<FactRecord[]> {
|
||||
return executor
|
||||
.selectFrom('facts')
|
||||
.innerJoin('fact_topics', 'fact_topics.fact_id', 'facts.id')
|
||||
.selectAll('facts')
|
||||
.where('facts.space_id', '=', spaceId)
|
||||
.where('fact_topics.topic_id', '=', topicId)
|
||||
.orderBy('facts.created_at', 'asc')
|
||||
.execute();
|
||||
@@ -26,6 +28,7 @@ export async function findFactRowsForTopicId(
|
||||
|
||||
export async function findFactRowsConnectingTopicIds(
|
||||
executor: DatabaseExecutor,
|
||||
spaceId: string,
|
||||
topicIds: string[],
|
||||
): Promise<FactRecord[]> {
|
||||
if (topicIds.length === 0) {
|
||||
@@ -36,6 +39,7 @@ export async function findFactRowsConnectingTopicIds(
|
||||
.selectFrom('facts')
|
||||
.innerJoin('fact_topics', 'fact_topics.fact_id', 'facts.id')
|
||||
.selectAll('facts')
|
||||
.where('facts.space_id', '=', spaceId)
|
||||
.where('fact_topics.topic_id', 'in', topicIds)
|
||||
.groupBy('facts.id')
|
||||
.having((eb) => eb.fn.count<number>('fact_topics.topic_id'), '=', topicIds.length)
|
||||
@@ -45,6 +49,7 @@ export async function findFactRowsConnectingTopicIds(
|
||||
|
||||
export async function findTopicLinksForFactIds(
|
||||
executor: DatabaseExecutor,
|
||||
spaceId: string,
|
||||
factIds: string[],
|
||||
): Promise<FactTopicJoinRow[]> {
|
||||
if (factIds.length === 0) {
|
||||
@@ -60,6 +65,7 @@ export async function findTopicLinksForFactIds(
|
||||
'fact_topics.role as role',
|
||||
'fact_topics.position as position',
|
||||
])
|
||||
.where('topics.space_id', '=', spaceId)
|
||||
.where('fact_topics.fact_id', 'in', factIds)
|
||||
.orderBy('fact_topics.position', 'asc')
|
||||
.execute() as Promise<FactTopicJoinRow[]>;
|
||||
|
||||
Reference in New Issue
Block a user