graphql-anywhere-mongodb
Version:
Use graphql to query mongodb
36 lines (35 loc) • 1.41 kB
TypeScript
import { MongoQueryInfo } from './graphql-to-mongo';
import { Db } from 'mongodb';
/**
* The result of executing a GraphQL query against MongoDB.
*/
export interface GraphQLExecutionResult {
/**
* The name of the collection that the query is for.
*/
collection: string;
/**
* The results of the query. Will be a single result for findOne and an array for find.
*/
results: any[] | any;
/**
* Any error that occurred as part of executing the query.
*/
error: Error;
}
/**
* Executes queries against multiple collections and returns all of their results.
*
* @param connection The mongodb connection.
* @param queryInfos An array of {MongoQueryInfo} to execute.
* @return {Promise<GraphQLExecutionResult[]>} The results of running all of the queries.
*/
export declare function findMultiple(connection: Db, queryInfos: MongoQueryInfo[]): Promise<GraphQLExecutionResult[]>;
/**
* Executes a single findOne query for the passed {MongoQueryInfo}.
* @param connection The mongodb connection.
* @param queryInfo The query {MongoQueryInfo} to execute.
* @return {Promise<GraphQLExecutionResult>} The results of running the query.
*/
export declare function findOne(connection: Db, queryInfo: MongoQueryInfo): Promise<GraphQLExecutionResult>;
export declare function findAll(connection: Db, queryInfo: MongoQueryInfo): Promise<GraphQLExecutionResult>;