Skip to content

Instantly share code, notes, and snippets.

@cdharris
Created February 5, 2021 11:15
Show Gist options
  • Save cdharris/ee5b2dd90cdb4adf9b88da65f4373790 to your computer and use it in GitHub Desktop.
Save cdharris/ee5b2dd90cdb4adf9b88da65f4373790 to your computer and use it in GitHub Desktop.
Memex Multi-content api explorations
class Indexer {
constructor(private storage, private tabManager) {}
async ensureIndexed(query: MetadataQuery) {
// Query the storage database, perhaps a cache first too to check if the query corrosponds to content already saved
if (record) {
return ContentMetadata(record)
} else {
// Ask the tab manager if it knows of a content currently open by that `query`
// If so do the full text database indexing
// wait for that (optional, could also schedule that for the bg)
// return the UUID
return ContentMetadata(createdRecord)
}
}
}
class TagRepository {
constructor(private storage,private indexer) {}
async addContentTagByQuery(query: MetadataQuery, tagId) {
const uuid = await indexer.ensureIndexed(query)
return storage.addContentTag(uuid,tagId)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment