3.0.0 • Published 1 year ago

query-builder-for-driveapi v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

license node-current version unpacked-size downloads

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, { // Class builder for generating queries
  FileType, // Enum with basic file types (mime types)
  VisibilityLevel // Enum with visibility levels
} from 'query-builder-for-driveapi'

Basic Usage

// Create an instance of QueryBuilder
const qb = new QueryBuilder()

// Add inputs (queries) to the query builder
qb.collection({ parents: 'parent-id' })
qb.fileName('test.txt')

// Build the query into a string
const query = qb.build()
//=> 'parent-id' in parents and name = 'test.txt' and trashed = false

!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({
  [K in Collection]?: string | string[]
})

Methods for fields

  • Equal to (=): $eq
  • Not equal to (≠): $ne
  • Contains (⊇): $contains
fileName(string | string[])
fileName({
  [K in Operator]?: string | string[]
})
fileType(string | string[])
fileType({
  [K in Operator]?: string | string[]
})
content(string | string[])
property({
  [K in string]: unknown | unknown[]
})
appProperty({
  [K in string]: unknown | unknown[]
})
  • Equal to (=): $eq
  • Not equal to (≠): $ne
visibility(string | string[])
visibility({
  [K in Operator]?: string | string[]
})
shortcutTargetId(string | string[])
shortcutTargetId({
  [K in Operator]?: string | string[]
})
orgDriveId(string | string[])
orgDriveId({
  [K in Operator]?: string | string[]
})
shared(boolean?) // default: true
trashed(boolean?) // default: true
starred(boolean?) // default: true
hidden(boolean?) // default: true
  • 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[]
})
updatedAt(string | string[])
updatedAt({
  [K in Operator]?: string | string[]
})
viewedAt(string | string[])
viewedAt({
  [K in Operator]?: string | string[]
})
organizerCount(number | number[])
organizerCount({
  [K in Operator]?: number | number[]
})
memberCount(number | number[])
memberCount({
  [K in Operator]?: number | number[]
})

Other Methods

negate(() => void)
const qb = new QueryBuilder()

// negates the queries in the callback
qb.negate(() => {
  qb.fileName('test.txt')
  qb.createdAt('2023-01-01')
})

qb.content('some content')

qb.build()
//=> not name = 'test.txt'
//      and not createdTime = '2023-01-01'
//      and fullText = 'some content'
//      and trashed = false
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.

3.0.0

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago