query-builder-for-driveapi
Easily generate queries for the Google Drive™ API.
Installation
npm install query-builder-for-driveapi
Get Started
Before we start with the basic usage, let's look at all the classes and enums exported from this package.
import QueryBuilder, {
FileType,
VisibilityLevel
} from 'query-builder-for-driveapi'
Basic Usage
const qb = new QueryBuilder()
qb.collection({ parents: 'parent-id' })
qb.fileName('test.txt')
const query = qb.build()
[!IMPORTANT]
To avoid "accidents", the build()
method adds a trashed = false
to the query by default.
Note: If you want to change this behavior in your query, simply call the trashed()
method before calling the build()
method.
Method for Collections
Collection | Method |
---|
parents |
collection({
[K in Collection]?: string | string[]
})
|
owners |
writers |
readers |
Methods for fields
Field | Operator (if applicable) | Method |
---|
name |
- Equal to (=):
$eq - Not equal to (≠):
$ne - Contains (⊇):
$contains
|
fileName(string | string[])
fileName({
[K in Operator]?: string | string[]
})
|
mimeType |
fileType(string | string[])
fileType({
[K in Operator]?: string | string[]
})
|
fullText | |
content(string | string[])
|
properties | |
property({
[K in string]: unknown | unknown[]
})
|
appProperties | |
appProperty({
[K in string]: unknown | unknown[]
})
|
visibility |
- Equal to (=):
$eq - Not equal to (≠):
$ne
|
visibility(string | string[])
visibility({
[K in Operator]?: string | string[]
})
|
shortcutDetails.targetId |
shortcutTargetId(string | string[])
shortcutTargetId({
[K in Operator]?: string | string[]
})
|
orgUnitId |
orgDriveId(string | string[])
orgDriveId({
[K in Operator]?: string | string[]
})
|
sharedWithMe | |
shared(boolean?)
|
trashed | |
trashed(boolean?)
|
starred | |
starred(boolean?)
|
hidden | |
hidden(boolean?)
|
createdTime |
- Equal to (=):
$eq - Not equal to (≠):
$ne - Less than (<):
$lt - Less than or equal to (≤):
$lte - Greater than (>):
$gt - Greater than or equal to (≥):
$gte
|
createdAt(string | string[])
createdAt({
[K in Operator]?: string | string[]
})
|
modifiedTime |
updatedAt(string | string[])
updatedAt({
[K in Operator]?: string | string[]
})
|
viewedByMeTime |
viewedAt(string | string[])
viewedAt({
[K in Operator]?: string | string[]
})
|
organizerCount |
organizerCount(number | number[])
organizerCount({
[K in Operator]?: number | number[]
})
|
memberCount |
memberCount(number | number[])
memberCount({
[K in Operator]?: number | number[]
})
|
Other Methods
Method | Sample |
---|
negate(() => void)
|
const qb = new QueryBuilder()
qb.negate(() => {
qb.fileName('test.txt')
qb.createdAt('2023-01-01')
})
qb.content('some content')
qb.build()
|
build()
|
Copyright & License
© 2023 Brian Fernandez
This project is licensed under the MIT license. See the file LICENSE for details.
Disclaimer
No affiliation with Google Inc.
This package is a third-party offering and is not a product of Google Inc.
Google Drive™ is a trademark of Google Inc.