1
0
Fork 0

more documentation, moved toString to shell.js

This commit is contained in:
Frank Celler 2011-12-02 09:57:29 +01:00
parent 49c33e85a0
commit 7c7222ee93
18 changed files with 394 additions and 138 deletions

View File

@ -34,6 +34,33 @@
#include <Basics/ProgramOptionsDescription.h>
#include <Rest/ApplicationServer.h>
////////////////////////////////////////////////////////////////////////////////
/// @page CommandLineLoggingTOC
///
/// <ol>
/// <li>General Logging Options</li>
/// <ol>
/// <li>log.file</li>
/// <li>log.severity</li>
/// <li>log.syslog</li>
/// </ol>
/// <li>Human Readable Logging</li>
/// <ol>
/// <li>log.level</li>
/// <li>log.line-number</li>
/// <li>log.prefix</li>
/// <li>log.thread</li>
/// </ol>
/// <li>Machine Readable Logging</li>
/// <ol>
/// <li>log.application</li>
/// <li>log.facility</li>
/// <li>log.format</li>
/// <li>log.hostname</li>
/// </ol>
/// </ol>
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @page CommandLineLogging Command-Line Options for Logging
///
@ -43,6 +70,13 @@
/// are used to provide statistics about executed requests and timings about
/// computation steps.
///
/// <hr>
/// @copydoc CommandLineLoggingTOC
///
////////////////////////////////////////////////////////////////////////////////
/// @section GeneralLogging General Logging Options
////////////////////////////////////////////////////////////////////////////////
///
/// @copydetails triagens::rest::ApplicationServerImpl::logFile
///
/// @copydetails triagens::rest::ApplicationServerImpl::logSeverity

View File

@ -30,6 +30,12 @@
#include "RestHandler/RestVocbaseBaseHandler.h"
////////////////////////////////////////////////////////////////////////////////
/// @page DefineAction Defining an Action
///
/// @copydetails JS_DefineAction
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- RestActionHandler
// -----------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@
#include "RestHandler/RestVocbaseBaseHandler.h"
////////////////////////////////////////////////////////////////////////////////
/// @page CRUDDocument CRUD for Documents
/// @page CRUDDocument REST Interface for Documents
///
/// The basic operations (create, read, update, delete) for documents are mapped
/// to the standard HTTP methods (POST, GET, PUT, DELETE). An identifier for the

View File

@ -39,16 +39,17 @@
///
/// The AvocadoDB has a REST interface for accessing the resources. It provides
/// a lightweight HTTP interface to execute actions. Actions are small
/// JavaScript functions which encapsulate business logic.
/// JavaScript functions which encapsulate business logic. Actions are
/// accessible via HTTP.
///
/// Next steps:
///
/// - learn more about the @ref RestInterface "REST interface"
/// - learn more about the @ref CRUDDocument "REST interface for documents"
/// - learn more about the @ref RestInterface "REST Interface"
/// - learn more about the @ref CRUDDocument "REST Interface for Documents"
///
/// Advanced Topis:
/// Advanced Topics:
///
/// - learn more about @ref Actions "actions"
/// - learn more about @ref Actions "Actions"
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@ -75,7 +76,7 @@
///
/// Next steps:
///
/// - learn more about the @ref CRUDDocument "REST interface for documents"
/// - learn more about the @ref CRUDDocument "REST Interface for Documents"
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------

View File

@ -186,6 +186,7 @@ void AvocadoServer::buildApplicationServer () {
_applicationAdminServer = ApplicationAdminServer::create(_applicationServer);
_applicationServer->addFeature(_applicationAdminServer);
_applicationAdminServer->allowAdminDirectory();
_applicationAdminServer->allowLogViewer();
_applicationAdminServer->allowVersion("avocado", TRIAGENS_VERSION);
@ -269,6 +270,7 @@ void AvocadoServer::buildApplicationServer () {
if (ok) {
LOGGER_FATAL << "action directory '" << path << "' must be a directory";
LOGGER_INFO << "please use the '--database.directory' option";
TRIAGENS_REST_SHUTDOWN;
exit(EXIT_FAILURE);
}
@ -277,6 +279,7 @@ void AvocadoServer::buildApplicationServer () {
if (! ok) {
LOGGER_FATAL << "cannot create action directory '" << path << "': " << TRI_last_error();
LOGGER_INFO << "please use the '--database.directory' option";
TRIAGENS_REST_SHUTDOWN;
exit(EXIT_FAILURE);
}
@ -312,6 +315,7 @@ void AvocadoServer::buildApplicationServer () {
if (_daemonMode) {
if (_pidFile.empty()) {
LOGGER_FATAL << "no pid-file defined, but daemon mode requested";
LOGGER_INFO << "please use the '--pid-file' option";
TRIAGENS_REST_SHUTDOWN;
exit(EXIT_FAILURE);
}
@ -319,6 +323,7 @@ void AvocadoServer::buildApplicationServer () {
if (_databasePath.empty()) {
LOGGER_FATAL << "no database path has been supplied, giving up";
LOGGER_INFO << "please use the '--database.directory' option";
TRIAGENS_REST_SHUTDOWN;
exit(EXIT_FAILURE);
}
@ -419,7 +424,7 @@ void AvocadoServer::executeShell () {
v8::Isolate* isolate;
v8::Persistent<v8::Context> context;
bool ok;
char const* files[] = { "shell.js", "json.js", "graph.js" };
char const* files[] = { "shell.js", "json.js" };
size_t i;
// only simple logging
@ -483,6 +488,7 @@ void AvocadoServer::executeShell () {
char* input = console->prompt("avocado> ");
if (input == 0) {
printf("bye...\n");
break;
}
@ -517,6 +523,7 @@ void AvocadoServer::openDatabase () {
if (_vocbase == 0) {
LOGGER_FATAL << "cannot open database '" << _databasePath << "'";
LOGGER_INFO << "please use the '--database.directory' option";
TRIAGENS_REST_SHUTDOWN;
exit(EXIT_FAILURE);
}

View File

@ -37,7 +37,16 @@ using namespace triagens::rest;
using namespace triagens::avocado;
////////////////////////////////////////////////////////////////////////////////
/// @page StartStop Starting and stopping
/// @page StartStopTOC
///
/// <ol>
/// <li>Frequently Used Options</li>
/// <li>Starting the Debug Shell</li>
/// </ol>
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @page StartStop Starting and Stopping the AvocadoDB
///
/// The AvocadoDB has two mode of operations: as server, where it will answer to
/// HTTP request, see @ref HttpInterface, and a debug shell, where you can
@ -45,6 +54,14 @@ using namespace triagens::avocado;
/// command normally available in actions and transactions, see @ref
/// AvocadoScript.
///
/// You should never start more than one server for the same database,
/// independent from the mode of operation.
///
/// <hr>
/// @copydoc StartStopTOC
///
/// @section StartStopOptions Frequently Used Options
///
/// The following main command-line options are available.
///
/// @copydetails triagens::avocado::AvocadoServer::_databasePath
@ -59,6 +76,10 @@ using namespace triagens::avocado;
/// server. The arg is specified as a string and can be one of the following
/// values: fatal, error, warning, info, debug, trace. For more information see
/// @ref CommandLineLogging "here".
///
/// @section StartStopShell Starting the Debug Shell
///
/// @verbinclude start1
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------

View File

@ -769,6 +769,9 @@ static string JS_graph =
" ine._inbound.push(edge);\n"
" }\n"
"\n"
" edge._inVertex = ine;\n"
" edge._outVertex = out;\n"
"\n"
" return edge;\n"
"}\n"
"\n"

View File

@ -143,7 +143,20 @@ static string JS_shell =
"\n"
"AvocadoCollection.prototype.print = function() {\n"
" if (this instanceof AvocadoCollection) {\n"
" output(\"[collection \\\"\", this._name, \"]\");\n"
" status = this.status();\n"
"\n"
" if (status == 1) {\n"
" output(\"[new born collection \", toJson(this._name), \"]\");\n"
" }\n"
" else if (status == 2) {\n"
" output(\"[unloaded collection \", toJson(this._name), \"]\");\n"
" }\n"
" else if (status == 3) {\n"
" output(\"[collection \", toJson(this._name), \"]\");\n"
" }\n"
" else {\n"
" output(\"[corrupted collection \", toJson(this._name), \"]\");\n"
" }\n"
" }\n"
" else {\n"
" output(this.toString(), \"\\n\");\n"
@ -151,6 +164,34 @@ static string JS_shell =
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief string representation of a collection\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"AvocadoCollection.prototype.toString = function() {\n"
" var status;\n"
"\n"
" if (this instanceof AvocadoCollection) {\n"
" status = this.status();\n"
"\n"
" if (status == 1) {\n"
" return \"[new born collection at \" + toJson(this._name) + \"]\";\n"
" }\n"
" else if (status == 2) {\n"
" return \"[unloaded collection at \" + toJson(this._name) + \"]\";\n"
" }\n"
" else if (status == 3) {\n"
" return \"[collection at \" + toJson(this._name) + \"]\";\n"
" }\n"
" else {\n"
" return \"[corrupted collection at \" + toJson(this._name) + \"]\";\n"
" }\n"
" }\n"
" else {\n"
" return \"[object]\";\n"
" }\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
@ -169,7 +210,7 @@ static string JS_shell =
"\n"
"AvocadoDatabase.prototype.print = function() {\n"
" if (this instanceof AvocadoDatabase) {\n"
" output(\"[vocbase at \\\"\", this._path, \"]\");\n"
" output(\"[vocbase at \", toJson(this._path), \"]\");\n"
" }\n"
" else {\n"
" output(this.toString(), \"\\n\");\n"
@ -177,6 +218,19 @@ static string JS_shell =
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief string representation of a vocbase\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"AvocadoDatabase.prototype.toString = function() {\n"
" if (this instanceof AvocadoDatabase) {\n"
" return \"[vocbase at \" + toJson(this._path) + \"]\";\n"
" }\n"
" else {\n"
" return \"[object]\";\n"
" }\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
@ -195,7 +249,7 @@ static string JS_shell =
"\n"
"AvocadoEdges.prototype.print = function() {\n"
" if (this instanceof AvocadoEdges) {\n"
" output(\"[edges at \\\"\", this._path, \"]\");\n"
" output(\"[edges at \", toJson(this._path), \"]\");\n"
" }\n"
" else {\n"
" output(this.toString(), \"\\n\");\n"
@ -203,6 +257,19 @@ static string JS_shell =
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief string representation of a vocbase\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"AvocadoEdges.prototype.toString = function() {\n"
" if (this instanceof AvocadoEdges) {\n"
" return \"[edges at \" + toJson(this._path) + \"]\";\n"
" }\n"
" else {\n"
" return \"[object]\";\n"
" }\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
@ -221,7 +288,7 @@ static string JS_shell =
"\n"
"AvocadoEdgesCollection.prototype.print = function() {\n"
" if (this instanceof AvocadoEdgesCollection) {\n"
" output(\"[edges collection \\\"\", this._name, \"]\");\n"
" output(\"[edges collection \", toJson(this._name), \"]\");\n"
" }\n"
" else {\n"
" output(this.toString(), \"\\n\");\n"

View File

@ -226,6 +226,34 @@ static action_options_t* ParseActionOptions (TRI_v8_global_t* v8g,
////////////////////////////////////////////////////////////////////////////////
/// @brief defines a new action
///
/// @FUN{defineAction(@FA{name}, @FA{callback})}
///
/// Defines an action named @FA{name}, which might contain slahes. The action
/// can be accessed using the path @c /_action/name. The callback function
/// is executed as soon as a request is received.
///
/// @FA{callback}(@FA{request}, @FA{response})
///
/// The request arguments contains a description of the request. A request
/// parameter @c foo is accessible as @c request.foo.
///
/// The callback must define the @FA{response}.
///
/// - @FA{response}.responseCode: the response code
/// - @FA{response}.contentType: the content type of the response
/// - @FA{response}.body: the body of the response
///
/// @FUN{defineAction(@FA{request}, @FA{response}, @FA{options})}
///
/// Normally the paramaters are passed to the callback as strings. You can
/// use the @FA{options}, to force a converstion of the parameter to
///
/// - @c "collection"
/// - @c "number"
/// - @c "string"
///
/// @verbinclude action1
////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_DefineAction (v8::Arguments const& argv) {

View File

@ -35,7 +35,7 @@
#include <VocBase/vocbase.h>
////////////////////////////////////////////////////////////////////////////////
/// @page Actions Actions
/// @page Actions First Steps with Actions
///
/// Actions are small JavaScript functions which are used to compute the result
/// of a request. Normally, the function will use the request parameter @a
@ -74,7 +74,24 @@
///
/// Next steps:
///
/// - learn about @ref ActionsQueryBuilding "query building functions"
/// - learn more about @ref DefineAction "Defining an Action"
/// - learn about @ref ActionsQueryBuilding "Query Building Functions"
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @page ActionsQueryBuildingTOC
///
/// <ol>
/// <li>all</li>
/// <li>distance</li>
/// <li>document</li>
/// <li>geo</li>
/// <li>limit</li>
/// <li>near</li>
/// <li>select</li>
/// <li>skip</li>
/// <li>within</li>
/// </ol>
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@ -82,6 +99,10 @@
///
/// The following functions can be used to build the result-set.
///
/// <hr>
/// @copydoc ActionsQueryBuildingTOC
/// <hr>
///
/// @copydetails JS_AllQuery
///
/// @copydetails JS_DistanceQuery

View File

@ -2131,10 +2131,10 @@ static v8::Handle<v8::Value> JS_SaveVocbaseCol (v8::Arguments const& argv) {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief converts a TRI_vocbase_col_t into a string
/// @brief returns the status of a collection
////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_ToStringVocbaseCol (v8::Arguments const& argv) {
static v8::Handle<v8::Value> JS_StatusVocbaseCol (v8::Arguments const& argv) {
v8::HandleScope scope;
TRI_vocbase_col_t const* collection = UnwrapClass<TRI_vocbase_col_t>(argv.Holder());
@ -2143,22 +2143,20 @@ static v8::Handle<v8::Value> JS_ToStringVocbaseCol (v8::Arguments const& argv) {
return scope.Close(v8::ThrowException(v8::String::New("illegal collection pointer")));
}
string name;
if (collection->_corrupted) {
name = "[corrupted collection \"" + string(collection->_name) + "\"]";
return scope.Close(v8::Number::New(4));
}
else if (collection->_newBorn) {
name = "[new born collection \"" + string(collection->_name) + "\"]";
return scope.Close(v8::Number::New(1));
}
else if (collection->_loaded) {
name = "[collection \"" + string(collection->_name) + "\"]";
return scope.Close(v8::Number::New(3));
}
else {
name = "[unloaded collection \"" + string(collection->_name) + "\"]";
return scope.Close(v8::Number::New(2));
}
return scope.Close(v8::String::New(name.c_str()));
return scope.Close(v8::Number::New(5));
}
////////////////////////////////////////////////////////////////////////////////
@ -2390,6 +2388,10 @@ static v8::Handle<v8::Value> MapGetVocBase (v8::Local<v8::String> name,
// convert the JavaScript string to a string
string key = TRI_ObjectToString(name);
if (key == "") {
return scope.Close(v8::ThrowException(v8::String::New("name must not be empty")));
}
if (key == "toString" || key == "print" || key[0] == '_') {
return v8::Handle<v8::Value>();
}
@ -2423,10 +2425,10 @@ static v8::Handle<v8::Value> MapGetVocBase (v8::Local<v8::String> name,
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief converts a TRI_vocbase_t into a string
/// @brief returns all collections
////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_ToStringVocBase (v8::Arguments const& argv) {
static v8::Handle<v8::Value> JS_CollectionsVocBase (v8::Arguments const& argv) {
v8::HandleScope scope;
TRI_vocbase_t* vocbase = UnwrapClass<TRI_vocbase_t>(argv.Holder());
@ -2435,9 +2437,18 @@ static v8::Handle<v8::Value> JS_ToStringVocBase (v8::Arguments const& argv) {
return scope.Close(v8::ThrowException(v8::String::New("corrupted vocbase")));
}
string name = "[vocbase at \"" + string(vocbase->_path) + "\"]";
v8::Handle<v8::Array> result = v8::Array::New();
TRI_vector_pointer_t colls = TRI_CollectionsVocBase(vocbase);
return scope.Close(v8::String::New(name.c_str()));
for (size_t i = 0; i < colls._length; ++i) {
TRI_vocbase_col_t const* collection = (TRI_vocbase_col_t const*) colls._buffer[i];
result->Set(i, TRI_WrapCollection(collection));
}
TRI_DestroyVectorPointer(&colls);
return scope.Close(result);
}
////////////////////////////////////////////////////////////////////////////////
@ -2477,6 +2488,10 @@ static v8::Handle<v8::Value> MapGetEdges (v8::Local<v8::String> name,
// convert the JavaScript string to a string
string key = TRI_ObjectToString(name);
if (key == "") {
return scope.Close(v8::ThrowException(v8::String::New("name must not be empty")));
}
if (key == "toString" || key == "print" || key[0] == '_') {
return v8::Handle<v8::Value>();
}
@ -2506,10 +2521,10 @@ static v8::Handle<v8::Value> MapGetEdges (v8::Local<v8::String> name,
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief converts a TRI_vocbase_t into a string
/// @brief returns all collections
////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
static v8::Handle<v8::Value> JS_CollectionsEdges (v8::Arguments const& argv) {
v8::HandleScope scope;
TRI_vocbase_t* vocbase = UnwrapClass<TRI_vocbase_t>(argv.Holder());
@ -2518,9 +2533,18 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
return scope.Close(v8::ThrowException(v8::String::New("corrupted vocbase")));
}
string name = "[edges at \"" + string(vocbase->_path) + "\"]";
v8::Handle<v8::Array> result = v8::Array::New();
TRI_vector_pointer_t colls = TRI_CollectionsVocBase(vocbase);
return scope.Close(v8::String::New(name.c_str()));
for (size_t i = 0; i < colls._length; ++i) {
TRI_vocbase_col_t const* collection = (TRI_vocbase_col_t const*) colls._buffer[i];
result->Set(i, TRI_WrapEdgesCollection(collection));
}
TRI_DestroyVectorPointer(&colls);
return scope.Close(result);
}
////////////////////////////////////////////////////////////////////////////////
@ -2534,44 +2558,32 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
////////////////////////////////////////////////////////////////////////////////
/// @page JavaScriptFuncIndex JavaScript Function Index
///
////////////////////////////////////////////////////////////////////////////////
/// @section JSFDatabaseSelection Database Selection
////////////////////////////////////////////////////////////////////////////////
///
/// - @ref MapGetVocBase "db".@FA{database}
///
/// - @ref MapGetVocBase "edges".@FA{database}
///
////////////////////////////////////////////////////////////////////////////////
/// @section JSFDatabases Database Functions
////////////////////////////////////////////////////////////////////////////////
///
/// - @ref JS_ParameterVocbaseCol "parameter"
///
////////////////////////////////////////////////////////////////////////////////
/// @subsection JSFDocument Database Document Functions
////////////////////////////////////////////////////////////////////////////////
///
/// - @ref JS_DeleteVocbaseCol "delete"
/// - @ref JS_ReplaceVocbaseCol "replace"
/// - @ref JS_SaveVocbaseCol "save"
/// - @ref JS_SaveEdgesCol "save" for edges
///
////////////////////////////////////////////////////////////////////////////////
/// @subsection JSFIndex Database Index Functions
////////////////////////////////////////////////////////////////////////////////
///
/// - @ref JS_DropIndexVocbaseCol "dropIndex"
/// - @ref JS_EnsureGeoIndexVocbaseCol "ensureGeoIndex"
/// - @ref JS_GetIndexesVocbaseCol "getIndexes"
///
////////////////////////////////////////////////////////////////////////////////
/// @section JSFQueries Query Functions
////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////
/// @subsection JSFQueryBuilding Query Building Functions
////////////////////////////////////////////////////////////////////////////////
///
/// - @ref JS_AllQuery "all"
/// - @ref JS_DistanceQuery "distance"
@ -2583,9 +2595,7 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
/// - @ref JS_SkipQuery "skip"
/// - @ref JS_WithinQuery "within"
///
////////////////////////////////////////////////////////////////////////////////
/// @subsection JSFQueryExecuting Query Execution Functions
////////////////////////////////////////////////////////////////////////////////
///
/// - @ref JS_CountQuery "count"
/// - @ref JS_ExplainQuery "explain"
@ -2594,9 +2604,7 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
/// - @ref JS_NextRefQuery "nextRef"
/// - @ref JS_ShowQuery "show"
///
////////////////////////////////////////////////////////////////////////////////
/// @section JSFGlobal Global Functions
////////////////////////////////////////////////////////////////////////////////
///
/// - @ref JS_FromJson "fromJson"
/// - @ref JSF_toJson "toJson"
@ -2611,21 +2619,15 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
////////////////////////////////////////////////////////////////////////////////
/// @page JavaScriptFunc JavaScript Functions
///
////////////////////////////////////////////////////////////////////////////////
/// @section JSFDatabaseSelection Database Selection
////////////////////////////////////////////////////////////////////////////////
///
/// @ref MapGetVocBase "db".@FA{database}
///
////////////////////////////////////////////////////////////////////////////////
/// @section JSFDatabases Database Functions
////////////////////////////////////////////////////////////////////////////////
///
/// @copydetails JS_ParameterVocbaseCol
///
////////////////////////////////////////////////////////////////////////////////
/// @subsection JSFDocument Database Document Functions
////////////////////////////////////////////////////////////////////////////////
///
/// @copydetails JS_DeleteVocbaseCol
///
@ -2635,9 +2637,7 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
///
/// @copydetails JS_SaveEdgesCol
///
////////////////////////////////////////////////////////////////////////////////
/// @subsection JSFIndex Database Index Functions
////////////////////////////////////////////////////////////////////////////////
///
/// @copydetails JS_DropIndexVocbaseCol
///
@ -2645,13 +2645,9 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
///
/// @copydetails JS_GetIndexesVocbaseCol
///
////////////////////////////////////////////////////////////////////////////////
/// @section JSFQueries Query Functions
////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////
/// @subsection JSFQueryBuilding Query Building Functions
////////////////////////////////////////////////////////////////////////////////
///
/// @copydetails JS_AllQuery
///
@ -2671,9 +2667,7 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
///
/// @copydetails JS_WithinQuery
///
////////////////////////////////////////////////////////////////////////////////
/// @subsection JSFQueryExecuting Query Execution Functions
////////////////////////////////////////////////////////////////////////////////
///
/// @copydetails JS_CountQuery
///
@ -2687,9 +2681,7 @@ static v8::Handle<v8::Value> JS_ToStringEdges (v8::Arguments const& argv) {
///
/// @copydetails JS_ShowQuery
///
////////////////////////////////////////////////////////////////////////////////
/// @section JSFGlobal Global Functions
////////////////////////////////////////////////////////////////////////////////
///
/// @copydetails JS_FromJson
///
@ -2835,6 +2827,7 @@ void TRI_InitV8VocBridge (v8::Handle<v8::Context> context, TRI_vocbase_t* vocbas
// .............................................................................
v8::Handle<v8::String> AllFuncName = v8::Persistent<v8::String>::New(v8::String::New("all"));
v8::Handle<v8::String> CollectionsFuncName = v8::Persistent<v8::String>::New(v8::String::New("_collections"));
v8::Handle<v8::String> CountFuncName = v8::Persistent<v8::String>::New(v8::String::New("count"));
v8::Handle<v8::String> DeleteFuncName = v8::Persistent<v8::String>::New(v8::String::New("delete"));
v8::Handle<v8::String> DistanceFuncName = v8::Persistent<v8::String>::New(v8::String::New("distance"));
@ -2859,6 +2852,7 @@ void TRI_InitV8VocBridge (v8::Handle<v8::Context> context, TRI_vocbase_t* vocbas
v8::Handle<v8::String> SelectFuncName = v8::Persistent<v8::String>::New(v8::String::New("select"));
v8::Handle<v8::String> ShowFuncName = v8::Persistent<v8::String>::New(v8::String::New("show"));
v8::Handle<v8::String> SkipFuncName = v8::Persistent<v8::String>::New(v8::String::New("skip"));
v8::Handle<v8::String> StatusFuncName = v8::Persistent<v8::String>::New(v8::String::New("status"));
v8::Handle<v8::String> ToArrayFuncName = v8::Persistent<v8::String>::New(v8::String::New("toArray"));
v8::Handle<v8::String> WithinFuncName = v8::Persistent<v8::String>::New(v8::String::New("within"));
@ -2889,10 +2883,10 @@ void TRI_InitV8VocBridge (v8::Handle<v8::Context> context, TRI_vocbase_t* vocbas
rt->SetNamedPropertyHandler(MapGetVocBase);
rt->Set(v8g->ToStringFuncName, v8::FunctionTemplate::New(JS_ToStringVocBase));
v8g->VocbaseTempl = v8::Persistent<v8::ObjectTemplate>::New(rt);
rt->Set(CollectionsFuncName, v8::FunctionTemplate::New(JS_CollectionsVocBase));
// must come after SetInternalFieldCount
context->Global()->Set(v8::String::New("AvocadoDatabase"),
ft->GetFunction());
@ -2909,7 +2903,7 @@ void TRI_InitV8VocBridge (v8::Handle<v8::Context> context, TRI_vocbase_t* vocbas
rt->SetNamedPropertyHandler(MapGetEdges);
rt->Set(v8g->ToStringFuncName, v8::FunctionTemplate::New(JS_ToStringEdges));
rt->Set(CollectionsFuncName, v8::FunctionTemplate::New(JS_CollectionsEdges));
v8g->EdgesTempl = v8::Persistent<v8::ObjectTemplate>::New(rt);
@ -2946,9 +2940,9 @@ void TRI_InitV8VocBridge (v8::Handle<v8::Context> context, TRI_vocbase_t* vocbas
rt->Set(SaveFuncName, v8::FunctionTemplate::New(JS_SaveVocbaseCol));
rt->Set(SelectFuncName, v8::FunctionTemplate::New(JS_SelectQuery));
rt->Set(SkipFuncName, v8::FunctionTemplate::New(JS_SkipQuery));
rt->Set(StatusFuncName, v8::FunctionTemplate::New(JS_StatusVocbaseCol));
rt->Set(ToArrayFuncName, v8::FunctionTemplate::New(JS_ToArrayQuery));
rt->Set(WithinFuncName, v8::FunctionTemplate::New(JS_WithinQuery));
rt->Set(v8g->ToStringFuncName, v8::FunctionTemplate::New(JS_ToStringVocbaseCol));
v8g->VocbaseColTempl = v8::Persistent<v8::ObjectTemplate>::New(rt);

View File

@ -486,7 +486,9 @@ TRI_vocbase_col_t const* TRI_LookupCollectionByIdVocBase (TRI_vocbase_t* vocbase
TRI_vocbase_col_t const* TRI_FindCollectionByNameVocBase (TRI_vocbase_t* vocbase, char const* name, bool bear) {
TRI_vocbase_col_t const* found;
TRI_ReadLockReadWriteLock(&vocbase->_lock);
found = TRI_LookupCollectionByNameVocBase(vocbase, name);
TRI_ReadUnlockReadWriteLock(&vocbase->_lock);
if (found != NULL) {
return found;
@ -499,6 +501,32 @@ TRI_vocbase_col_t const* TRI_FindCollectionByNameVocBase (TRI_vocbase_t* vocbase
return TRI_BearCollectionVocBase(vocbase, name);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns all known collections
////////////////////////////////////////////////////////////////////////////////
TRI_vector_pointer_t TRI_CollectionsVocBase (TRI_vocbase_t* vocbase) {
TRI_vector_pointer_t result;
TRI_vocbase_col_t* found;
size_t i;
TRI_InitVectorPointer(&result);
TRI_ReadLockReadWriteLock(&vocbase->_lock);
for (i = 0; i < vocbase->_collectionsById._nrAlloc; ++i) {
found = vocbase->_collectionsById._table[i];
if (found != NULL) {
TRI_PushBackVectorPointer(&result, found);
}
}
TRI_ReadUnlockReadWriteLock(&vocbase->_lock);
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a new (document) collection
////////////////////////////////////////////////////////////////////////////////

View File

@ -321,6 +321,12 @@ TRI_vocbase_col_t const* TRI_LookupCollectionByIdVocBase (TRI_vocbase_t*, TRI_vo
TRI_vocbase_col_t const* TRI_FindCollectionByNameVocBase (TRI_vocbase_t*, char const*, bool bear);
////////////////////////////////////////////////////////////////////////////////
/// @brief returns all known collections
////////////////////////////////////////////////////////////////////////////////
TRI_vector_pointer_t TRI_CollectionsVocBase (TRI_vocbase_t* vocbase);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a new (document) collection
////////////////////////////////////////////////////////////////////////////////

View File

@ -1 +1 @@
#define TRIAGENS_VERSION "0.0.4 (9650)"
#define TRIAGENS_VERSION "0.0.4 (9650:9661)"

View File

@ -5,29 +5,19 @@
///
/// DISCLAIMER
///
/// Copyright by triAGENS GmbH - All rights reserved.
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
///
/// 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.
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// 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.
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// 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.
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///

View File

@ -768,6 +768,9 @@ Graph.prototype.addEdge = function (out, ine, label, data) {
ine._inbound.push(edge);
}
edge._inVertex = ine;
edge._outVertex = out;
return edge;
}

View File

@ -5,29 +5,19 @@
///
/// DISCLAIMER
///
/// Copyright by triAGENS GmbH - All rights reserved.
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
///
/// 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.
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// 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.
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// 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.
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
@ -57,7 +47,7 @@ function toJson (x, useNL, indent) {
if (x === null) {
return "null";
}
if (x === undefined) {
return "undefined";
}
@ -124,7 +114,7 @@ Array.prototype.toJson = function(useNL, indent) {
if (! indent) {
indent = "";
}
if (! useNL) {
indent = "";
}
@ -159,17 +149,17 @@ Array.prototype.toJson = function(useNL, indent) {
Object.prototype.toJson = function(useNL, indent) {
var nl = useNL ? "\n" : " ";
if (! indent) {
indent = "";
}
var s = "{" + nl;
// push one level of indent
var oldIndent = indent;
indent += " ";
if (! useNL) {
indent = "";
}

View File

@ -5,29 +5,19 @@
///
/// DISCLAIMER
///
/// Copyright by triAGENS GmbH - All rights reserved.
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
///
/// 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.
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// 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.
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// 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.
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
@ -142,13 +132,54 @@ Object.prototype.print = function() {
AvocadoCollection.prototype.print = function() {
if (this instanceof AvocadoCollection) {
output("[collection \"", this._name, "]");
status = this.status();
if (status == 1) {
output("[new born collection ", toJson(this._name), "]");
}
else if (status == 2) {
output("[unloaded collection ", toJson(this._name), "]");
}
else if (status == 3) {
output("[collection ", toJson(this._name), "]");
}
else {
output("[corrupted collection ", toJson(this._name), "]");
}
}
else {
output(this.toString(), "\n");
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief string representation of a collection
////////////////////////////////////////////////////////////////////////////////
AvocadoCollection.prototype.toString = function() {
var status;
if (this instanceof AvocadoCollection) {
status = this.status();
if (status == 1) {
return "[new born collection at " + toJson(this._name) + "]";
}
else if (status == 2) {
return "[unloaded collection at " + toJson(this._name) + "]";
}
else if (status == 3) {
return "[collection at " + toJson(this._name) + "]";
}
else {
return "[corrupted collection at " + toJson(this._name) + "]";
}
}
else {
return "[object]";
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
@ -168,13 +199,26 @@ AvocadoCollection.prototype.print = function() {
AvocadoDatabase.prototype.print = function() {
if (this instanceof AvocadoDatabase) {
output("[vocbase at \"", this._path, "]");
output("[vocbase at ", toJson(this._path), "]");
}
else {
output(this.toString(), "\n");
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief string representation of a vocbase
////////////////////////////////////////////////////////////////////////////////
AvocadoDatabase.prototype.toString = function() {
if (this instanceof AvocadoDatabase) {
return "[vocbase at " + toJson(this._path) + "]";
}
else {
return "[object]";
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
@ -194,13 +238,26 @@ AvocadoDatabase.prototype.print = function() {
AvocadoEdges.prototype.print = function() {
if (this instanceof AvocadoEdges) {
output("[edges at \"", this._path, "]");
output("[edges at ", toJson(this._path), "]");
}
else {
output(this.toString(), "\n");
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief string representation of a vocbase
////////////////////////////////////////////////////////////////////////////////
AvocadoEdges.prototype.toString = function() {
if (this instanceof AvocadoEdges) {
return "[edges at " + toJson(this._path) + "]";
}
else {
return "[object]";
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
@ -220,7 +277,7 @@ AvocadoEdges.prototype.print = function() {
AvocadoEdgesCollection.prototype.print = function() {
if (this instanceof AvocadoEdgesCollection) {
output("[edges collection \"", this._name, "]");
output("[edges collection ", toJson(this._name), "]");
}
else {
output(this.toString(), "\n");