How to I search using Google Drive API using Javascript?

一曲冷凌霜 提交于 2019-12-24 09:08:26

问题


I am currently working with Google Drive API and search files.

 var test = false;

    gapi.client.drive.files.list({
      pageSize: x,
      q: "starred = test and viewedByMeTime > '2016-06-01T12:00:00-08:00', and not 'testemail@gmail.com' in writers",
      orderBy: 'viewedByMeTime desc',
      spaces: 'drive',
      fields: "nextPageToken, files(id, name, viewedByMeTime, mimeType)",
     }

    )

The issue I am having is that I want to be able to set var test = to false or true depending on whats the user selected. However, I can't put variable test in the parameter for it to work. How do I make it so starred = test will mean the same thing as starred = false?

I've tried:

q: "starred = '"+test+"' and viewedByMeTime > '2016-06-01T12:00:00-08:00' and not 'testemail@gmail.com' in writers",

but it also doesnt seem to work. Help would be much appreciated.

Also, any good guides on Google Drive API and javascript would help too! Thanks!

Edit #1: Additionally, how can I set viewByMeTime and in writers to variables as well? Do I change it to

viewedByMeTime > "'+variable+'" and not "'+variable+'" in writers? 

How do I set the variables for dates and collections?


回答1:


Starred should be a boolean, not a string. Try removing your inner quotes.

q: "starred = "+test+" and viewedByMeTime > '2016-06-01T12:00:00-08:00' and not 'testemail@gmail.com' in writers",



来源:https://stackoverflow.com/questions/42687476/how-to-i-search-using-google-drive-api-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!