Skip to content

Commit

Permalink
feat: distinguish between different connectiont types
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Mar 27, 2017
1 parent 5ebcf55 commit 8407806
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ import {
NotFoundError
} from './errors';
import type {
InternalQueryInsertType,
DatabasePoolConnectionType,
DatabaseSingleConnectionType,
InternalQueryAnyType,
InternalQueryOneType,
InternalQueryInsertType,
InternalQueryManyType,
InternalQueryType,
DatabaseConnectionType
InternalQueryOneType,
InternalQueryType
} from './types';

export type {
DatabaseConnectionType
DatabaseConnectionType,
DatabasePoolConnectionType,
DatabaseSingleConnectionType
} from './types';

export {
Expand Down Expand Up @@ -114,7 +117,7 @@ export const any: InternalQueryAnyType = async (connection, sql, values) => {
};

// eslint-disable-next-line flowtype/no-weak-types
const createConnection = async (configuration: Object): Promise<DatabaseConnectionType> => {
const createConnection = async (configuration: Object): Promise<DatabaseSingleConnectionType> => {
const connection = await createConnection2(configuration);

return {
Expand All @@ -130,7 +133,7 @@ const createConnection = async (configuration: Object): Promise<DatabaseConnecti
};

// eslint-disable-next-line flowtype/no-weak-types
const createPool = (configuration: Object): DatabaseConnectionType => {
const createPool = (configuration: Object): DatabasePoolConnectionType => {
const pool = createPool2(configuration);

return {
Expand Down
9 changes: 7 additions & 2 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
// eslint-disable-next-line flowtype/no-weak-types
type InternalDatabaseConnectionType = any;

export type DatabaseConnectionType = {|
export type DatabaseSingleConnectionType = {
end: () => Promise<void>
} & DatabaseConnectionType;
export type DatabasePoolConnectionType = DatabaseConnectionType;

export type DatabaseConnectionType = {
+any: QueryAnyType,
+insert: QueryInsertType,
+many: QueryManyType,
+one: QueryOneType,
+query: QueryType
|};
};

type QueryPointResultType = {|
+x: number,
Expand Down

0 comments on commit 8407806

Please sign in to comment.