From 952b4fc73a7cde1892b5ad864254932e9f0dece7 Mon Sep 17 00:00:00 2001 From: Joshua Hendrix <56802866+thejoshuahendrix@users.noreply.github.com> Date: Fri, 17 Dec 2021 14:29:28 -0500 Subject: [PATCH] Add basic comments for methods (#11) * added basic comments for methods * Update ScylloClient.ts --- src/ScylloClient.ts | 59 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/src/ScylloClient.ts b/src/ScylloClient.ts index 603843c..c9a5fc7 100644 --- a/src/ScylloClient.ts +++ b/src/ScylloClient.ts @@ -23,7 +23,7 @@ export type ScylloClientOptions = { log?: LogMethod; /** * Verbose, - * Wether or not to output verbose information on each request. + * Whether or not to output verbose information on each request. */ debug?: boolean; }; @@ -31,7 +31,7 @@ export type ScylloClientOptions = { const fromObjScyllo = (row: types.Row) => Object.assign( {}, - ...row.keys().map((k) => ({ [k]: fromScyllo(row.get(k)) })) + ...row.keys().map((item: any) => ({ [item]: fromScyllo(row.get(item)) })) ); export class ScylloClient { keyspace: string = 'scyllo'; @@ -45,11 +45,17 @@ export class ScylloClient { this.debug = options.debug || false; this.log = options.log || console.log; } - + /** + * Await the connection + * to the client. + */ async awaitConnection(): Promise { return await this.client.connect(); } - + /** + * Shutdown a + * client instance + */ async shutdown(): Promise { return await this.client.shutdown(); } @@ -78,7 +84,10 @@ export class ScylloClient { return await this.raw(`USE ${keyspace};`); } - + /** + * Select from + * a table and return based on criteria. + */ async selectFrom( table: F, select: '*' | C[], @@ -96,7 +105,10 @@ export class ScylloClient { return result.rows.map(fromObjScyllo) as Pick[]; } - + /** + * Select one from + * a table and return based on criteria. + */ async selectOneFrom( table: F, select: '*' | C[], @@ -117,7 +129,10 @@ export class ScylloClient { C >; } - + /** + * Insert an object into + * a table. + */ async insertInto( table: F, obj: Partial @@ -126,7 +141,10 @@ export class ScylloClient { return await this.query(query); } - + /** + * Update an entry in + * a table. + */ async update( table: F, obj: Partial, @@ -141,7 +159,10 @@ export class ScylloClient { return await this.query(query); } - + /** + * Delete from + * a table based on criteria. + */ async deleteFrom( table: F, fields: '*' | (keyof TableMap[F])[], @@ -158,19 +179,28 @@ export class ScylloClient { return await this.query(query); } - + /** + * Truncate + * a certain table. + */ async truncateTable( table: F ): Promise { return await this.rawWithParams('TRUNCATE ?', [table]); } - + /** + * Delete + * a table. + */ async dropTable( table: F ): Promise { return await this.rawWithParams('DROP TABLE ?', [table]); } - + /** + * Create + * a table. + */ async createTable( table: F, createIfNotExists: boolean, @@ -191,7 +221,10 @@ export class ScylloClient { return await this.query(query); } - + /** + * Create + * a keyspace. + */ async createKeyspace( keyspace: string, replicationClass = 'SimpleStrategy',