Query Builder for DriveAPI
Easily generate queries for the Google Drive API.
📦 Installation
npm install query-builder-for-driveapi
🚀 Quick start
How to import
import QueryBuilder from 'query-builder-for-driveapi'
const QueryBuilder = require('query-builder-for-driveapi').default
How to build a query
-
Create a new instance
const query = new QueryBuilder()
-
Add inputs
query.inParents('folderId')
query.name().contains('something')
or
query.inParents('folderId').name().contains('something')
-
Build query
query.build()
Methods
Commonly used terms and operators are supported. You can find a list of all those supported by the Drive API at Google Developers.
Terms
Term | Method | Return | Description |
---|
parents | inParents(folderId: string) | Instance | Indicates whether the parent collection contains the specified ID. |
name | name() | Instance | Select the term name to be used with methods like: contains() , isEqualTo() and isNotEqualTo() |
fullText | fullText() | Instance | Select the term fullText to be used with methods like: contains() |
mimeType | mimeType() | Instance | Select the term mimeType to be used with methods like: contains() , isEqualTo() and isNotEqualTo() |
modifiedTime | modifiedTime() | Instance | Select the term modifiedTime to be used with methods like: isLessThan() , isLessThanOrEqualTo() , isEqualTo() , isNotEqualTo() , isGreaterThanOrEqualTo() and isGreaterThan() |
createdTime | createdTime() | Instance | Select the term createdTime to be used with methods like: isLessThan() , isLessThanOrEqualTo() , isEqualTo() , isNotEqualTo() , isGreaterThanOrEqualTo() and isGreaterThan() |
Operators
Operator | Method | Return | Description |
---|
contains | contains(value: string) | Instance | N/A |
= | isEqualTo(value: string) | Instance | N/A |
!= | isNotEqualTo(value: string) | Instance | N/A |
< | isLessThan(value: string) | Instance | N/A |
<= | isLessThanOrEqualTo(value: string) | Instance | N/A |
> | isGreaterThan(value: string) | Instance | N/A |
>= | isGreaterThanOrEqualTo(value: string) | Instance | N/A |
not | not() | Instance | Negate the following term. |
Build
Method | Return | Description |
---|
build() | String | Returns a string with the inputs joined with the and operator. |
License
MIT License © 2023 - Brian Fernandez