Read bibliographic records with their identity fields from the local database
zotLocalRecords.RdReturns, for every non-trashed regular item, the fields that
zotSameItem() compares: DOI, title, date and its year, the family name of
the first author, and whether the item carries a file. Attachments, notes
and annotations are not records and are excluded. See zotLocalQuery() for
synchronization and read-only details.
Usage
zotLocalRecords(
library = NULL,
path = file.path(Sys.getenv("HOME"), "Zotero", "zotero.sqlite")
)Value
A data.table with itemKey, groupID (0 for personal),
itemType, title, doi, date, year, author and hasFile.
Details
author is the family name of the creator of type author with the lowest
order; a record without an author has NA there and can only match by DOI
or file. hasFile is TRUE when a child attachment is an imported or
linked file (linkMode 0, 1 or 2); a linked URL is not a file. year is
the first four-digit year found in date, the same rule as
zotIdentity().
Examples
Path <- tempfile(fileext = ".sqlite")
Connection <- DBI::dbConnect(RSQLite::SQLite(), Path)
DBI::dbWriteTable(Connection, "libraries", data.frame(libraryID = 1L))
DBI::dbWriteTable(Connection, "groups",
data.frame(libraryID = integer(), groupID = integer()))
DBI::dbWriteTable(Connection, "itemTypes",
data.frame(itemTypeID = 1L, typeName = "journalArticle"))
DBI::dbWriteTable(Connection, "items", data.frame(
itemID = 1L, key = "AAA", libraryID = 1L, itemTypeID = 1L,
dateAdded = "2026-01-01", dateModified = "2026-01-01"
))
DBI::dbWriteTable(Connection, "fieldsCombined", data.frame(
fieldID = c(110L, 26L, 14L), fieldName = c("title", "DOI", "date")
))
DBI::dbWriteTable(Connection, "itemData", data.frame(
itemID = 1L, fieldID = c(110L, 26L, 14L), valueID = 1:3
))
DBI::dbWriteTable(Connection, "itemDataValues", data.frame(
valueID = 1:3, value = c("A record", "10.1000/x", "2026-03-01")
))
DBI::dbWriteTable(Connection, "creatorTypes",
data.frame(creatorTypeID = 1L, creatorType = "author"))
DBI::dbWriteTable(Connection, "creators", data.frame(
creatorID = 1L, firstName = "Ada", lastName = "Lovelace"
))
DBI::dbWriteTable(Connection, "itemCreators", data.frame(
itemID = 1L, creatorID = 1L, creatorTypeID = 1L, orderIndex = 0L
))
DBI::dbWriteTable(Connection, "itemAttachments", data.frame(
itemID = integer(), parentItemID = integer(), linkMode = integer(),
contentType = character(), path = character(), storageHash = character()
))
DBI::dbWriteTable(Connection, "deletedItems", data.frame(itemID = integer()))
DBI::dbDisconnect(Connection)
zotLocalRecords(path = Path)
#> itemKey groupID itemType title doi date year author
#> <char> <int> <char> <char> <char> <char> <char> <char>
#> 1: AAA 0 journalArticle A record 10.1000/x 2026-03-01 2026 Lovelace
#> hasFile
#> <lgcl>
#> 1: FALSE
unlink(Path)