Namespace: oak

oak

Methods

(static) blobStats() → {object}

Returns statistics about the blobs collection in the current database. The stats include the combined BSON size of all documents. The time to run this command therefore heavily depends on the size of the collection.
Source:
Returns:
statistics about the blobs collection.
Type
object

(static) checkDeepHistory(path, verboseopt)

Same as checkHistory except it goes through ALL descendants as well!
Parameters:
Name Type Attributes Default Description
path string the path of the document.
verbose boolean <optional>
false if true, the result object will contain a list of dangling references to previous documents.
Source:

(static) checkHistory(path, verboseopt, ignorePathLenopt) → {object}

Checks the history of previous documents at the given path. Orphaned references to removed previous documents are counted and listed when run with verbose set to true.
Parameters:
Name Type Attributes Default Description
path string the path of the document.
verbose boolean <optional>
false if true, the result object will contain a list of dangling references to previous documents.
ignorePathLen boolean <optional>
false whether to ignore a long path and still try to read it from MongoDB.
Source:
Returns:
the result of the check.
Type
object

(static) checkLastRevs(path, clusterId) → {object}

Checks the _lastRev for a given clusterId. The checks starts with the given path and walks up to the root node.
Parameters:
Name Type Description
path string the path of a node to check
clusterId number the id of an oak cluster node.
Source:
Returns:
the result of the check.
Type
object

(static) countChildren(path) → {number}

Determines the number of child node (including all sub tree) for a given parent node path. This would be faster compared to getChildStats as it does not load the doc and works on index only. Note that there might be some difference between db.nodes.count() and countChildren('/') as split docs, intermediate docs are not accounted for
Parameters:
Name Type Description
path string the path of a node.
Source:
Returns:
the number of children, including all descendant nodes.
Type
number

(static) findOne(path) → {object}

Finds the document with the given path.
Parameters:
Name Type Description
path string the path of the document.
Source:
Returns:
the document or null if it doesn't exist.
Type
object

(static) fixDeepHistory(path, verboseopt)

Same as fixHistory except it goes through ALL descendants as well!
Parameters:
Name Type Attributes Default Description
path string the path of the document.
verbose boolean <optional>
false if true, the result object will contain a list of removed references to previous documents.
Source:

(static) fixHistory(path, verboseopt) → {object}

Repairs the history of previous documents at the given path. Orphaned references to removed previous documents are cleaned up and listed when run with verbose set to true.
Parameters:
Name Type Attributes Default Description
path string the path of the document.
verbose boolean <optional>
false if true, the result object will contain a list of removed references to previous documents.
Source:
Returns:
the result of the fix.
Type
object

(static) fixLastRevs(path, clusterId) → {object}

Fixes the _lastRev for a given clusterId. The fix starts with the given path and walks up to the root node.
Parameters:
Name Type Description
path string the path of a node to fix
clusterId number the id of an oak cluster node.
Source:
Returns:
the result of the fix.
Type
object

(static) forEachChild(path, callable)

Performs a breadth first traversal for nodes under given path and invokes the passed function for each child node.
Parameters:
Name Type Description
path string the path of a node.
callable a function to be called for each child node including all descendant nodes. The MongoDB document is passed as the single parameter of the function.
Source:

(static) formatRevision(rev) → {string}

Converts the given Revision String into a more human readable version, which also prints the date.
Parameters:
Name Type Description
rev string a revision string.
Source:
Returns:
a human readable string representation of the revision.
Type
string

(static) getChildStats(path) → {Object}

Provides stats related to number of child nodes below given path or total size taken by such nodes.
Parameters:
Name Type Description
path string the path of a node.
Source:
Returns:
statistics about the child nodes including all descendants.
Type
Object

(static) getCommitValue(path, revision) → {object}

Returns the commit value entry for the change with the given revision.
Parameters:
Name Type Description
path string the path of a document.
revision string the revision of a change on the document.
Source:
Returns:
the commit entry for the given revision or null if there is none.
Type
object

(static) indexStats() → {Array}

Collects various stats related to Oak indexes stored under /oak:index.
Source:
Returns:
index stats.
Type
Array

(static) listCheckpoints() → {object}

List all checkpoints.
Source:
Returns:
all checkpoints
Type
object

(static) listChildren(path)

Lists the children at a given path.
Parameters:
Name Type Description
path string list the children of the document with this path.
Source:

(static) listDescendants(path)

Lists the descendant documents at a given path.
Parameters:
Name Type Description
path string list the descendants of the document with this path.
Source:

(static) pathFromId(id) → {string}

Returns the path part of the given id.
Parameters:
Name Type Description
id string the id of a Document in the nodes collection.
Source:
Returns:
the path derived from the id.
Type
string

(static) prepareDeepHistory(path, verboseopt)

Preparation step which scans through all descendants and prints out 'fixHistory' for those that need fixing of their 'dangling references'.

See fixHistory for parameter details.

Run this command via something as follows:

mongo <DBNAME> -eval "load('oak-mongo.js'); oak.prepareDeepHistory('/');" > fix.js

Parameters:
Name Type Attributes Default Description
path string the path of a document.
verbose boolean <optional>
false if true, the result object will contain a list of dangling references to previous documents.
Source:

(static) printMongoExportCommand(path, options) → {string}

Prints mongoexport command to export all documents related to given path. Related documents refer to all documents in the hierarchy and their split documents. e.g. > oak.printMongoExportCommand("/etc", {db: "aem-author"})
Parameters:
Name Type Description
path string the path of the document.
options object pass optional parameters for host, port, db, and filename
Source:
Returns:
command line which can be used to export documents using mongoexport
Type
string

(static) printOplogSliceCommand(revStr, options) → {string}

Prints mongoexport command to export oplog entries around time represented by revision. e.g. > oak.printOplogSliceCommand("r14e64620028-0-1", {db: "aem-author"}) Note, this assumed that time on mongo instance is synchronized with time on oak instance. If that's not the case, then adjust revStr to account for the difference.
Parameters:
Name Type Description
revStr string revision string around which oplog is to be exported.
options object pass optional parameters for host, port, db, filename, oplogTimeBuffer
Source:
Returns:
command line which can be used to export oplog entries using mongoexport
Type
string

(static) removeCheckpointsOlderThan(rev) → {object}

Removes all checkpoints older than a given Revision.
Parameters:
Name Type Description
rev string checkpoints older than this revision are removed.
Source:
Returns:
the result of the MongoDB update.
Type
object

(static) removeCollisions(path, clusterId) → {object}

Removes all collision markers on the document with the given path and clusterId. This method will only remove collisions when the clusterId is inactive.
Parameters:
Name Type Description
path string the path of a document
clusterId number collision markers for this clusterId will be removed.
Source:
Returns:
the result of the MongoDB update.
Type
object

(static) removeDescendantsAndSelf(path)

Removes the complete subtree rooted at the given path.
Parameters:
Name Type Description
path string the path of the subtree to remove.
Source:

(static) systemStats() → {object}

Collects various stats related to Oak usage of Mongo.
Source:
Returns:
system stats.
Type
object