Skip to main content

Home > git-documentdb > GitDocumentDB

GitDocumentDB class#

Main class of GitDocumentDB

Signature:
export declare class GitDocumentDB implements GitDDBInterface, CRUDInterface, CollectionInterface, SyncEventInterface
Implements:

GitDDBInterface , CRUDInterface , CollectionInterface , SyncEventInterface

Remarks#

Call open() before using DB.

Constructors#

ConstructorModifiersDescription
(constructor)(options)Constructor

Properties#

PropertyModifiersTypeDescription
author{ name: string; email: string; }Author name and email for commit
committer{ name: string; email: string; }Committer name and email for commit
dbIdstringGet dbId
dbNamestringA name of a Git repository
defaultBranch(not declared)Default Git branch
isClosingbooleanDB is going to close
isOpenedbooleanTest if a database is opened
localDirstringA local directory path that stores repositories of GitDocumentDB
loggerColoredLoggerGet logger
logLevelTLogLevelNamelogLevel ('silly' | 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal')
logToTransport((logObject: ILogObject) => void) | undefinedlogToTransport function for all log levels. See https://tslog.js.org/\#/?id=transports
rootCollectionICollectionDefault collection whose collectionPath is ''.
schemaSchemaSchema for specific document type
serializeFormatSerializeFormatJSON | SerializeFormatFrontMatter
taskQueueTaskQueueTask queue
tsLoggerLoggerGet logger
validatorValidatorName validator
workingDirstringGet a full path of the current Git working directory

Methods#

MethodModifiersDescription
close(options)Close a database
collection(collectionPath, options)Get a collection
delete(_id, options)Delete a JSON document
delete(jsonDoc, options)Delete a document by _id property in JsonDoc
deleteFatDoc(name, options)Delete a data
destroy(options)Destroy a database
find(options)Get all the JSON documents
findFatDoc(options)Get all the FatDoc data
get(_id)Get a JSON document
getCollections(dirPath)Get collections
getCommit(oid)Get a commit object
getDocByOid(fileOid, docType)Get a Doc which has specified oid
getFatDoc(name, getOptions)Get a FatDoc data
getFatDocHistory(name, historyOptions, getOptions)Get revision history of a FatDoc data
getFatDocOldRevision(name, revision, historyOptions, getOptions)Get an old revision of a FatDoc data
getHistory(_id, historyOptions)Get revision history of a document
getOldRevision(_id, revision, historyOptions)Get an old revision of a document
getRemoteURLs()getRemoteURLs
getSync(remoteURL)Get synchronizer
insert(jsonDoc, options)Insert a JSON document
insert(_id, jsonDoc, options)Insert a JSON document
insertFatDoc(name, doc, options)Insert a data
loadAuthor()Load author from .git/config
offSyncEvent(remoteURL, event, callback)Remove SyncEvent handler
offSyncEvent(sync, event, callback)Remove SyncEvent handler
onSyncEvent(remoteURL, event, callback)Add SyncEvent handler
onSyncEvent(sync, event, callback)Add SyncEvent handler
open(openOptions)Open or create a Git repository
plugin(obj)static
put(jsonDoc, options)Insert a JSON document if not exists. Otherwise, update it.
put(_id, jsonDoc, options)Insert a JSON document if not exists. Otherwise, update it.
putFatDoc(name, doc, options)Insert data if not exists. Otherwise, update it.
removeSync(remoteURL)Stop and unregister remote synchronization
saveAuthor()Save current author to .git/config
sync(options)Synchronize with a remote repository
sync(options, getSyncResult)Synchronize with a remote repository
update(jsonDoc, options)Update a JSON document
update(_id, jsonDoc, options)Update a JSON document
updateFatDoc(name, doc, options)Update a data