问题描述
我目前正在使用Google Drive API和搜索文件。
var test = false;
gapi.client.drive.files.list({
pageSize:x,
q:starred = test and viewedByMeTime>'2016-06-01T12:00:00 -08:00',而不是'[email protected]'在作家中,
orderBy:'viewedByMeTime desc',
spaces:'drive',
fields:nextPageToken,files (id,name,viewedByMeTime,mimeType),
}
)
我遇到的问题是,我希望能够根据用户选择的内容将var test =设置为false或true。但是,我无法将变量测试放入参数中以使其正常工作。
$ b p
我试过了:
$ b $我如何使它成为starred = test将意味着与starred = false相同的内容? b
q:starred ='+ test +'and viewedByMeTime>'2016-06-01T12:00:00-08:00'而不是'testemail @ gmail。 com'in writers,
但它似乎不起作用。帮助将不胜感激。
另外,有关Google Drive API和JavaScript的任何优秀指南都会有所帮助!感谢!
编辑#1:另外,我怎样才能设置viewByMeTime,以及编写者的变量?我是否将其更改为
viewedByMeTime> '+ variable +'而不是'+ variable +'在作家中?
如何为日期和集合设置变量?
q:starred =+ test +and viewedByMeTime>'2016-06-01T12:00:00 -08:00'而不是'[email protected]',
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 '[email protected]' 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 '[email protected]' 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?
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 '[email protected]' in writers",
这篇关于如何使用Javascript使用Google Drive API进行搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!