Gathering detailed insights and metrics for @gmmurray/mongodb-atlas-data-api
Gathering detailed insights and metrics for @gmmurray/mongodb-atlas-data-api
Gathering detailed insights and metrics for @gmmurray/mongodb-atlas-data-api
Gathering detailed insights and metrics for @gmmurray/mongodb-atlas-data-api
A client library for interacting with the Atlas Data API.
npm install @gmmurray/mongodb-atlas-data-api
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
6 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jul 16, 2023
Latest Version
1.1.0
Package Id
@gmmurray/mongodb-atlas-data-api@1.1.0
Unpacked Size
42.84 kB
Size
9.10 kB
File Count
11
NPM Version
6.14.3
Node Version
18.12.0
Published on
Aug 14, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
6
A client library for interacting with the Atlas Data API.
This library requires the following dependencies:
1$ npm install axios
These instructions will help you get started with using the Atlas Data API Client in your project.
To install the library, run the following command:
1$ npm install atlas-data-api-client
Alternatively, you can use Yarn:
1$ yarn add atlas-data-api-client
In these examples we use a made up customer interface:
1interface Customer { 2 id: string; 3 name: string; 4 age: number; 5}
1import AtlasDataApiClient, { 2 AtlasDataApiClientOptions, 3} from '@gmmurray/atlas-data-api-client'; 4 5const options: AtlasDataApiClientOptions = { 6 apiKey: 'YOUR_API_KEY', 7 dataApiUrlEndpoint: 'your-app-url-endpoint', 8 defaultDataSource: 'your-default-data-source', 9 defaultDatabase: 'your-default-database', 10}; 11 12const apiClient = new AtlasDataApiClient(options);
1const request: FindOneDocumentRequest<Customer> = { 2 collection: 'your-collection', 3 filter: { name: 'John Doe' }, 4}; 5 6const response: FindOneApiResponse<Customer> = await apiClient.findOneDocument( 7 request, 8); 9 10console.log(response);
1const request: FindManyDocumentsRequest<Customer> = { 2 collection: 'your-collection', 3 filter: { age: { $gte: 18 } }, 4 sort: { name: 1 }, 5 pageSize: 10, 6 pageNumber: 1, 7}; 8 9const response: FindManyApiResponse<Customer> = await apiClient.findDocuments( 10 request, 11); 12 13console.log(response);
1const request: InsertOneDocumentRequest<Customer> = { 2 collection: 'your-collection', 3 document: { name: 'John Doe', age: 25 }, 4}; 5 6const response: InsertOneApiResponse = await apiClient.insertOneDocument( 7 request, 8); 9 10console.log(response);
1const request: InsertManyDocumentsRequest<Customer> = { 2 collection: 'your-collection', 3 documents: [ 4 { name: 'John Doe', age: 25 }, 5 { name: 'Jane Smith', age: 30 }, 6 ], 7}; 8 9const response: InsertManyApiResponse = await apiClient.insertManyDocuments( 10 request, 11); 12 13console.log(response);
1const request: UpdateOneDocumentRequest<Customer> = { 2 collection: 'your-collection', 3 filter: { id: '123' }, 4 update: { name: 'John Doe', age: 26 }, 5 upsert: true, 6}; 7 8const response: UpdateOneApiResponse = await apiClient.updateOneDocument( 9 request, 10); 11 12console.log(response);
1const request: UpdateManyDocumentsRequest<Customer> = { 2 collection: 'your-collection', 3 filter: { age: { $gte: 18 } }, 4 update: { status: 'active' }, 5 upsert: true, 6}; 7 8const response: UpdateManyApiResponse = await apiClient.updateManyDocuments( 9 request, 10); 11 12console.log(response);
1const request: ReplaceOneDocumentRequest<Customer> = { 2 collection: 'your-collection', 3 filter: { id: '123' }, 4 replacement: { id: '123', name: 'John Doe', age: 27 }, 5 upsert: true, 6}; 7 8const response: ReplaceOneApiResponse = await apiClient.replaceOneDocument( 9 request, 10); 11 12console.log(response);
1const request: DeleteOneDocumentRequest<Customer> = { 2 collection: 'your-collection', 3 filter: { id: '123' }, 4}; 5 6const response: DeleteOneApiResponse = await apiClient.deleteOneDocument( 7 request, 8); 9 10console.log(response);
1const request: DeleteManyDocumentsRequest<Customer> = { 2 collection: 'your-collection', 3 filter: { age: { $gte: 18 } }, 4}; 5 6const response: DeleteManyApiResponse = await apiClient.deleteManyDocuments( 7 request, 8); 9 10console.log(response);
1const request: AggregateDocumentsRequest = { 2 collection: 'your-collection', 3 pipeline: [ 4 { $match: { age: { $gte: 18 } } }, 5 { $group: { _id: '$gender', count: { $sum: 1 } } }, 6 ], 7}; 8 9const response: AggregateApiResponse = await apiClient.aggregateDocuments( 10 request, 11); 12 13console.log(response);
Method | Description |
---|---|
findOneDocument(request: FindOneDocumentRequest | Finds a single document in the specified collection. |
findDocuments(request: FindManyDocumentsRequest | Finds multiple documents in the specified collection. |
insertOneDocument(request: InsertOneDocumentRequest | Inserts a single document into the specified collection. |
insertManyDocuments(request: InsertManyDocumentsRequest | Inserts multiple documents into the specified collection. |
updateOneDocument(request: UpdateOneDocumentRequest | Updates a single document in the specified collection. |
updateManyDocuments(request: UpdateManyDocumentsRequest | Updates multiple documents in the specified collection. |
replaceOneDocument(request: ReplaceOneDocumentRequest | Replaces a single document in the specified collection. |
deleteOneDocument(request: DeleteOneDocumentRequest | Deletes a single document from the specified collection. |
deleteManyDocuments(request: DeleteManyDocumentsRequest | Deletes multiple documents from the specified collection. |
aggregateDocuments(request: AggregateDocumentsRequest): Promise | Performs an aggregation on the specified collection. |
For more details on each method and their request/response types, please refer to the source code documentation.
No vulnerabilities found.
No security vulnerabilities found.