mirror of https://gitee.com/bigwinds/arangodb
292 lines
10 KiB
JavaScript
292 lines
10 KiB
JavaScript
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief JavaScript server functions
|
|
///
|
|
/// @file
|
|
///
|
|
/// DISCLAIMER
|
|
///
|
|
/// Copyright by triAGENS GmbH - All rights reserved.
|
|
///
|
|
/// The Programs (which include both the software and documentation)
|
|
/// contain proprietary information of triAGENS GmbH; they are
|
|
/// provided under a license agreement containing restrictions on use and
|
|
/// disclosure and are also protected by copyright, patent and other
|
|
/// intellectual and industrial property laws. Reverse engineering,
|
|
/// disassembly or decompilation of the Programs, except to the extent
|
|
/// required to obtain interoperability with other independently created
|
|
/// software or as specified by law, is prohibited.
|
|
///
|
|
/// The Programs are not intended for use in any nuclear, aviation, mass
|
|
/// transit, medical, or other inherently dangerous applications. It shall
|
|
/// be the licensee's responsibility to take all appropriate fail-safe,
|
|
/// backup, redundancy, and other measures to ensure the safe use of such
|
|
/// applications if the Programs are used for such purposes, and triAGENS
|
|
/// GmbH disclaims liability for any damages caused by such use of
|
|
/// the Programs.
|
|
///
|
|
/// This software is the confidential and proprietary information of
|
|
/// triAGENS GmbH. You shall not disclose such confidential and
|
|
/// proprietary information and shall use it only in accordance with the
|
|
/// terms of the license agreement you entered into with triAGENS GmbH.
|
|
///
|
|
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
|
///
|
|
/// @author Dr. Frank Celler
|
|
/// @author Copyright 2011, triAGENS GmbH, Cologne, Germany
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- Array
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Shell V8 Shell
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief JSON representation of an array
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Array.prototype.print = function() {
|
|
if (this.length == 0) {
|
|
output("[ ]");
|
|
}
|
|
else {
|
|
var sep = " ";
|
|
|
|
output("[");
|
|
|
|
for (var i = 0; i < this.length; i++) {
|
|
output(sep);
|
|
print(this[i]);
|
|
sep = ", ";
|
|
}
|
|
|
|
output(" ]");
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- Function
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Shell V8 Shell
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief JSON representation of a function
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Function.prototype.print = function() {
|
|
output(this.toString());
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- Object
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Shell V8 Shell
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief string representation of an object
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Object.prototype.print = function() {
|
|
var sep = " ";
|
|
|
|
output("{");
|
|
|
|
for (var k in this) {
|
|
if (this.hasOwnProperty(k)) {
|
|
var val = this[k];
|
|
|
|
output(sep, k, " : ");
|
|
print(val);
|
|
sep = ", ";
|
|
}
|
|
}
|
|
|
|
output(" }");
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- AvocadoCollection
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Shell V8 Shell
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief prints a collection
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
AvocadoCollection.prototype.print = function() {
|
|
if (this instanceof AvocadoCollection) {
|
|
output("[collection \"", this._name, "]");
|
|
}
|
|
else {
|
|
output(this.toString(), "\n");
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- AvocadoDatabase
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Shell V8 Shell
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief prints the vocbase
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
AvocadoDatabase.prototype.print = function() {
|
|
if (this instanceof AvocadoDatabase) {
|
|
output("[vocbase at \"", this._path, "]");
|
|
}
|
|
else {
|
|
output(this.toString(), "\n");
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- AvocadoEdges
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Shell V8 Shell
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief prints the edges base
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
AvocadoEdges.prototype.print = function() {
|
|
if (this instanceof AvocadoEdges) {
|
|
output("[edges at \"", this._path, "]");
|
|
}
|
|
else {
|
|
output(this.toString(), "\n");
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- AvocadoEdgesCollection
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Shell V8 Shell
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief prints an edges collection
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
AvocadoEdgesCollection.prototype.print = function() {
|
|
if (this instanceof AvocadoEdgesCollection) {
|
|
output("[edges collection \"", this._name, "]");
|
|
}
|
|
else {
|
|
output(this.toString(), "\n");
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// --SECTION-- AvocadoQuery
|
|
// -----------------------------------------------------------------------------
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @addtogroup V8Shell V8 Shell
|
|
/// @{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief global variable holding the current printed query
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
var it = undefined;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief number of results to print
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
var queryLimit = 20;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief prints a query
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
AvocadoQuery.prototype.print = function() {
|
|
if (this instanceof AvocadoQuery) {
|
|
var count = 0;
|
|
|
|
try {
|
|
while (this.hasNext() && count++ < queryLimit) {
|
|
print(this.next());
|
|
output("\n");
|
|
}
|
|
|
|
if (this.hasNext()) {
|
|
output("...more results...");
|
|
}
|
|
|
|
it = this;
|
|
}
|
|
catch (e) {
|
|
output("encountered error while printing: " + e);
|
|
}
|
|
}
|
|
else {
|
|
output(this.toString(), "\n");
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @}
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Local Variables:
|
|
// mode: outline-minor
|
|
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\)"
|
|
// End:
|