Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitlab.com/mxmz/google-drive-query-builder

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitlab.com/mxmz/google-drive-query-builder

  • v0.0.0-20200804213353-858215a36f0a
  • Source
  • Go
  • Socket score

Version published
Created
Source

Google Drive query builder

This package helps build search queries for Google Drive Search API.

Drive files.list API and search syntax are documented here:

Usage

The example below searches for documents matching the following criteria:

  • ( content-type is text/plain AND name includes "Foo" ) OR name is "pluto"
  • AND document was created less than 10 hours ago
package main

import (
	"context"
	"fmt"
	"log"
	q "gitlab.com/mxmz/google-drive-query-builder/query"
	"golang.org/x/oauth2/google"
	drive "google.golang.org/api/drive/v3"
)

func main() {

	var stm1 = q.MimeType().Equal("text/plain")
	var stm2 = q.Name().Contains("Foo")

	var query = q.
		Query(stm1).
		And(stm2).
		Or(q.Raw(`name = "pluto"`)).
		And(q.CreatedTime().After(time.Now().Add(-10 * time.Hour)))


	ctx := context.Background()
	client, _ := google.DefaultClient(ctx, drive.DriveScope)
	driveSvc, _ := drive.New(client)

	var svc = drive.NewFilesService(driveSvc)
	lst, _ := svc.List().
		Q(q.Stringize(query)).
		Fields("files(name,createdTime,properties)").
		OrderBy("createdTime").
		PageSize(1000).
		Do()

	for _, v := range lst.Files {

		log.Printf("%s %v \n", v.Name, v.CreatedTime)

	}


}

FAQs

Package last updated on 04 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc