PgCollectionStore

org.llm4s.rag.permissions.pg.PgCollectionStore
final class PgCollectionStore(getConnection: () => Connection, vectorTableName: String) extends CollectionStore

PostgreSQL implementation of CollectionStore.

Manages the collection hierarchy with permission inheritance.

Value parameters

getConnection

Function to obtain a database connection

vectorTableName

Name of the vectors table (for document/chunk counts)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def canQuery(path: CollectionPath, auth: UserAuthorization): Result[Boolean]

Check if a user can query a collection.

Check if a user can query a collection.

This considers the effective permissions (with inheritance).

Value parameters

auth

The user's authorization context

path

The collection path

Attributes

Returns

True if the user can query this collection

Definition Classes
override def countChunks(path: CollectionPath): Result[Long]

Count chunks in a collection.

Count chunks in a collection.

Value parameters

path

The collection path

Attributes

Returns

Number of chunks

Definition Classes
override def countDocuments(path: CollectionPath): Result[Long]

Count documents in a collection.

Count documents in a collection.

Value parameters

path

The collection path

Attributes

Returns

Number of documents (not chunks)

Definition Classes
override def create(config: CollectionConfig): Result[Collection]

Create a new collection.

Create a new collection.

Validates that:

  • The parent exists (if not a root collection)
  • Permissions don't loosen parent restrictions
  • The path is valid and not already taken

Value parameters

config

The collection configuration

Attributes

Returns

The created collection, or error

Definition Classes
override def delete(path: CollectionPath): Result[Unit]

Delete a collection.

Delete a collection.

The collection must be empty (no documents or sub-collections).

Value parameters

path

The collection path

Attributes

Returns

Success or error

Definition Classes

Ensure a collection exists, creating it if necessary.

Ensure a collection exists, creating it if necessary.

Creates parent collections as needed (as public, non-leaf).

Value parameters

config

The collection configuration

Attributes

Returns

The existing or newly created collection

Definition Classes
override def findAccessible(auth: UserAuthorization, pattern: CollectionPattern): Result[Seq[Collection]]

Find collections accessible by user matching a pattern.

Find collections accessible by user matching a pattern.

This is the key permission-filtered query used during search. Returns only collections where:

  • Pattern matches, AND
  • User has access (public OR user's principals overlap with queryableBy)

Also respects inheritance - if a parent is not accessible, its children are also not accessible.

Value parameters

auth

The user's authorization context

pattern

The pattern to match

Attributes

Returns

Accessible collections matching the pattern

Definition Classes
override def get(path: CollectionPath): Result[Option[Collection]]

Get a collection by path.

Get a collection by path.

Value parameters

path

The collection path

Attributes

Returns

The collection if found, None otherwise

Definition Classes
override def getById(id: Int): Result[Option[Collection]]

Get a collection by its database ID.

Get a collection by its database ID.

Value parameters

id

The collection ID

Attributes

Returns

The collection if found, None otherwise

Definition Classes

Get effective permissions for a collection considering inheritance.

Get effective permissions for a collection considering inheritance.

Effective permissions are the intersection of:

  • The collection's own queryableBy, AND
  • All ancestor collections' queryableBy sets

If any ancestor is public (empty queryableBy), that level is skipped. If the collection itself is public, returns empty (meaning public).

Value parameters

path

The collection path

Attributes

Returns

The effective permissions set

Definition Classes
override def list(pattern: CollectionPattern): Result[Seq[Collection]]

List all collections matching a pattern.

List all collections matching a pattern.

Does NOT apply permission filtering - returns all matching collections. Use findAccessible for permission-filtered queries.

Value parameters

pattern

The pattern to match (default: all)

Attributes

Returns

All matching collections

Definition Classes
override def listChildren(parentPath: CollectionPath): Result[Seq[Collection]]

List direct children of a collection.

List direct children of a collection.

Value parameters

parentPath

The parent collection path

Attributes

Returns

Direct child collections

Definition Classes
override def stats(path: CollectionPath): Result[CollectionStats]

Get collection statistics.

Get collection statistics.

Value parameters

path

The collection path

Attributes

Returns

Collection statistics

Definition Classes
override def updateMetadata(path: CollectionPath, metadata: Map[String, String]): Result[Collection]

Update collection metadata.

Update collection metadata.

Value parameters

metadata

The new metadata (replaces existing)

path

The collection path

Attributes

Returns

The updated collection, or error

Definition Classes
override def updatePermissions(path: CollectionPath, queryableBy: Set[PrincipalId]): Result[Collection]

Update collection permissions.

Update collection permissions.

Validates that new permissions don't loosen parent restrictions.

Value parameters

path

The collection path

queryableBy

The new set of queryable principals

Attributes

Returns

The updated collection, or error

Definition Classes

Inherited methods

def exists(path: CollectionPath): Result[Boolean]

Check if a collection exists.

Check if a collection exists.

Value parameters

path

The collection path

Attributes

Returns

True if exists

Inherited from:
CollectionStore