@narodb/naro
Version:
A simple, fast, and lightweight NoSQL database
26 lines • 1.25 kB
TypeScript
export declare class NaroPath {
/**
* Validates a given path string and extracts its components.
*
* @param {string} path - The path string to validate. It should follow the format:
* 'collectionName/id' or 'collectionName/id/subCollectionName/id'.
*
* @returns {Object} An object containing the extracted components of the path:
* - `collectionName` (string): The name of the collection.
* - `collectionId` (string): The ID of the collection.
* - `subCollectionName` (string | undefined): The name of the sub-collection (if present).
* - `subCollectionId` (string | undefined): The ID of the sub-collection (if present).
*
* @throws {Error} If the path contains invalid characters.
* @throws {Error} If the path ends with a '/'.
* @throws {Error} If the path is empty.
* @throws {Error} If the path format is invalid (e.g., too few or too many parts).
*/
static validate(path: string): {
collectionName: string;
collectionId: string;
subCollectionName?: string;
subCollectionId?: string;
};
}
//# sourceMappingURL=NaroPath.d.ts.map