Skip to main content

Repository

Extends: Emitter

Constructor

new Repository(db: GoatDB<>, path: string, trustPool: TrustPool<>, __namedParameters: RepositoryConfig<ST>)

Methods

changedFieldsInCommit()

changedFieldsInCommit(commit: string | Commit<>): string[]

This method computes a quick diff between the given commit and all of its parents. It determines which fields were changed in this commit, rather than what the changes were.

commitIsCorrupted()

commitIsCorrupted(c: Commit<>): boolean

commitIsHighProbabilityLeaf()

commitIsHighProbabilityLeaf(candidate: string | Commit<>): boolean

This method determines, to a high probability, whether the given commit is a leaf commit or not, even when the full graph isn't available.

It works by inspecting the bloom filters of the newest 2log[4](N) commits, and checking for the presence of the candidate commit. If present in all filters, the commit guaranteed not to be a leaf.

commits()

commits(session: Session): Generator<Commit<>>

commitsForKey()

commitsForKey(key: string, session: Session): Generator<Commit<>>

create()

create(key: string, value: Item<S>): Promise<Commit<>>

debugNetworkForKey()

debugNetworkForKey(key: string): ReadonlyJSONObject

downloadDebugNetworkForKey()

downloadDebugNetworkForKey(key: string): void

findLatestAncestorFromCommit()

findLatestAncestorFromCommit(commit: string | Commit<>, filter: (c: Commit<>) => boolean): Commit<>

findLatestNonCorruptedCommitForKey()

findLatestNonCorruptedCommitForKey(key: string): Commit<>

findMergeBase()

findMergeBase(commits: Commit<>[]): [commits: Commit<>[], base: Commit<>, scheme: Schema, reachedRoot: boolean]

Given an iterable of commits, this method returns their Lowest Common Ancestor or undefined if no such ancestor exists (meaning the commits belong to disconnected histories).

findNonCorruptedParentsFromCommits()

findNonCorruptedParentsFromCommits(parents: string | Commit<>[]): Commit<>[]

getCommit()

getCommit(id: string, session: Session): Commit<>

graphForKey()

graphForKey(key: string): CommitGraph[]

hasCommit()

hasCommit(id: string): boolean

hasItemForCommit()

hasItemForCommit(c: string | Commit<>): boolean

hasKey()

hasKey(key: string): boolean

headForKey()

headForKey(key: string): Commit<>

This method finds and returns the head for the given key. This is a readonly operation and does not attempt to merge any leaves.

itemForCommit()

itemForCommit(c: string | Commit<>): Item<S>

keyExists()

keyExists(key: string): boolean

keys()

keys(session: Session): Iterable<string>

leavesForKey()

leavesForKey(key: string, session: Session): readonly Commit<>[]

mergeIfNeeded()

mergeIfNeeded(key: string): Promise<Commit<>>

numberOfCommits()

numberOfCommits(session: Session): number

paths()

paths(session: Session): Iterable<string>

persistCommits()

persistCommits(commits: Iterable<Commit<>>): Promise<Commit<>[]>

persistVerifiedCommits()

persistVerifiedCommits(commits: Iterable<Commit<>>): Promise<Commit<>[]>

rebase()

rebase(key: string, record: Item<S>, headId: string | Commit<>): [Item<S>, string]

Given a key and an edited record for this key, this method rebases the changes from the record on top of the any changes made concurrently for this key. Use it to merge remote changes with any local edits before committing them.

revertAllKeysToBefore()

revertAllKeysToBefore(ts: number): void

revertHeadsByConnectionId()

revertHeadsByConnectionId(connectionIds: string | string[]): void

setValueForKey()

setValueForKey(key: string, value: Item<S>, parentCommit: string | Commit<>): Promise<Commit<>>

Updates the head record for a given key.

valueForKey()

valueForKey(key: string): [Item<T>, Commit<>]

verifyCommits()

verifyCommits(commits: Iterable<Commit<>>): Promise<Commit<>[]>

normalizePath()

normalizePath(id: string): string

parseId()

parseId(id: string): [storage: string, id: string]

path()

path(storage: string, id: string): string

Inherited Methods

From Emitter

attach(), detach(), detachAll(), emit(), mute(), once(), resume(), suspend(), unmute()

See Emitter for detailed documentation