问题
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