docudb
Version:
Document-based NoSQL database for NodeJS
65 lines • 2.13 kB
TypeScript
/**
* File Storage Module
* Handles file reading/writing and chunks for the database
*/
import { Document, StorageOptions } from '../types/index.js';
declare class FileStorage {
/** Directory to store data */
dataDir: string;
/** Maximum size of each chunk in bytes */
chunkSize: number;
/** Indicates if compression should be used */
useCompression: boolean;
/** File extension for chunks */
chunkExt: string;
/**
* Creates a new file storage instance
* @param options - Configuration options
*/
constructor(options: StorageOptions);
/**
* Initializes storage by creating necessary directories
*/
initialize(): Promise<void>;
/**
* Splits data into appropriately sized chunks
* @param {string} data - Data to split
* @returns {string[]} - Array of chunks
* @private
*/
private _splitIntoChunks;
/**
* Saves data to a file, possibly splitting it into chunks
* @param {string} collectionName - Collection name
* @param {Object} data - Data to save
* @returns {Promise<string[]>} - List of created chunk paths
*/
saveData(collectionName: string, data: Object): Promise<string[]>;
/**
* Reads data from a set of chunks
* @param {string[]} chunkPaths - Paths of chunks to read
* @returns {Promise<Document>} - Combined data
*/
readData(chunkPaths: string[]): Promise<Document>;
/**
* Deletes a set of chunks
* @param {string[]} chunkPaths - Paths of chunks to delete
*/
deleteChunks(chunkPaths: string[]): Promise<void>;
/**
* Ensures that the collection directory exists
* @param {string} collectionName - Collection name
* @private
*/
_ensureCollectionDir(collectionName: string): Promise<string>;
/**
* Generates the path for a chunk
* @param {string} collectionName - Collection name
* @param {number} chunkIndex - Chunk index
* @returns {string} - Chunk path
* @private
*/
private _getChunkPath;
}
export default FileStorage;
//# sourceMappingURL=fileStorage.d.ts.map