SambalCollection

Index data from content$ observable into user specified collections

SambalCollection

Index data from content$ observable into user specified collections

constructor(private collections: CollectionDef[], private userOptions: StoreOptions = {})

Parameters:

(Required) collections: List of collection definitions

(Optional) userOptions.cacheFolder: Folder to store indexed data. Default to ./.sambal

Collection schema


{
    name: string,                                       // REQUIRED - Name of your collection
    groupBy?: string | string[],                        // OPTIONAL - Group by fieldname(s). Field value has to be string, number, date, or an array of one of these types
    sortBy?: [{field: string, order: "desc" | "asc"}]   // OPTIONAL - Sort by fieldname(s) and the order.  Field value has to be string, number, or date
}

Public functions

indexContent(content$): Promise<void>

Index data from contentPath and content$ observable into user specified collections

Parameters:

(Required) content$: Content data observable

collection(name: string, partition?: object): Observable<any>

Return observable of data from specified collection

Parameters:

(Required) name: Name of collection

(Optional) partition: Partition key of the groupBy partition. i.e. {username: "user1"}

stats(collectionName: string): Promise<object>

Return size of specified collection

Parameters:

(Required) collectionName: Name of collection

Examples