Addresses #971, Add support for secondary key
Zotero.Items.getByKey(key) -- retrieve an Item object by its secondary lookup key No caching yet -- if this becomes a bottleneck, I'll add some
This commit is contained in:
parent
ee589b0ed5
commit
566a338c98
1 changed files with 17 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
||||||
Zotero.Items = new function() {
|
Zotero.Items = new function() {
|
||||||
// Privileged methods
|
// Privileged methods
|
||||||
this.get = get;
|
this.get = get;
|
||||||
|
this.getByKey = getByKey;
|
||||||
this.exist = exist;
|
this.exist = exist;
|
||||||
this.getAll = getAll;
|
this.getAll = getAll;
|
||||||
this.getUpdated = getUpdated;
|
this.getUpdated = getUpdated;
|
||||||
|
@ -101,6 +102,22 @@ Zotero.Items = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves an item by its secondary lookup key
|
||||||
|
*
|
||||||
|
* @param string key Secondary lookup key
|
||||||
|
* @return object Zotero.Item object, or FALSE if not found
|
||||||
|
*/
|
||||||
|
function getByKey(key) {
|
||||||
|
var sql = "SELECT itemID FROM items WHERE key=?";
|
||||||
|
var itemID = Zotero.DB.valueQuery(sql, key);
|
||||||
|
if (!itemID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Zotero.Items.get(itemID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function exist(itemIDs) {
|
function exist(itemIDs) {
|
||||||
var sql = "SELECT itemID FROM items WHERE itemID IN ("
|
var sql = "SELECT itemID FROM items WHERE itemID IN ("
|
||||||
+ itemIDs.map(function () '?').join() + ")";
|
+ itemIDs.map(function () '?').join() + ")";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue