Easily generate queries for the Google Drive API.
npm install query-builder-for-driveapi
// ECMAScript
import QueryBuilder from 'query-builder-for-driveapi'
// CommonJS
const QueryBuilder = require('query-builder-for-driveapi').default
-
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() // return string
Commonly used terms and operators are supported. You can find a list of all those supported by the Drive API at Google Developers.
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() |
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. |
Method | Return | Description |
---|---|---|
build() |
String | Returns a string with the inputs joined with the and operator. |
MIT License © 2023 - Brian Fernandez