mirror of https://gitee.com/bigwinds/arangodb
documentation and minor fixes
This commit is contained in:
parent
9876db22cd
commit
cb016351e8
|
@ -0,0 +1,2 @@
|
|||
avocado> db.examples.properties()
|
||||
{ "waitForSync" : false, "journalSize" : 33554432 }
|
|
@ -0,0 +1,2 @@
|
|||
avocado> db.examples.properties({ waitForSync : false })
|
||||
{ "waitForSync" : false, "journalSize" : 33554432 }
|
|
@ -0,0 +1,4 @@
|
|||
avocado> c = db._create("cars");
|
||||
[AvocadoCollection 111137, "cars" (status loaded)]
|
||||
avocado> c.properties()
|
||||
{ "waitForSync" : false, "journalSize" : 33554432 }
|
|
@ -0,0 +1,4 @@
|
|||
avocado> c = db._create("cars", { waitForSync : true, journalSize : 1024 * 1204 });
|
||||
[AvocadoCollection 96384, "cars" (status loaded)]
|
||||
avocado> c.properties()
|
||||
{ "waitForSync" : true, "journalSize" : 1232896 }
|
|
@ -0,0 +1,4 @@
|
|||
avocado> db.examples.load();
|
||||
avocado> var d = db.demo;
|
||||
avocado> db._collections();
|
||||
[[AvocadoCollection 96393, "examples" (status loaded)], [AvocadoCollection 1407113, "demo" (status new born)]]
|
|
@ -1,2 +1,2 @@
|
|||
avocado> db._collection(145387)
|
||||
avocado> db._collection(145387);
|
||||
[AvocadoCollection 145387, "demo" (status loaded)]
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
avocado> db._collection("demo")
|
||||
avocado> db._collection("demo");
|
||||
[AvocadoCollection 145387, "demo" (status loaded)]
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
avocado> db.examples;
|
||||
[AvocadoCollection 110371, "examples" (status new born)]
|
|
@ -313,6 +313,7 @@ WIKI = \
|
|||
HttpCollection \
|
||||
HttpIndex \
|
||||
HttpInterface \
|
||||
HttpSystem \
|
||||
IndexGeo \
|
||||
IndexHash \
|
||||
IndexSkiplist \
|
||||
|
|
|
@ -44,11 +44,6 @@
|
|||
/// <li>@ref Indexes
|
||||
/// @copydetails IndexesTOC
|
||||
/// </li>
|
||||
/// <li>Shell Commands
|
||||
/// <ol>
|
||||
/// <li>@ref ShellDocument</li>
|
||||
/// </ol>
|
||||
/// </li>
|
||||
/// <li>@ref OTWP
|
||||
/// <ol>
|
||||
/// <li>@ref RestDocument</li>
|
||||
|
@ -58,6 +53,12 @@
|
|||
/// <li>@ref HttpSystem</li>
|
||||
/// </ol>
|
||||
/// </li>
|
||||
/// <li>Shell Commands
|
||||
/// <ol>
|
||||
/// <li>@ref ShellDocument</li>
|
||||
/// <li>@ref ShellCollection</li>
|
||||
/// </ol>
|
||||
/// </li>
|
||||
/// </ol>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -41,12 +41,12 @@
|
|||
/// @page RestDocumentCallsTOC
|
||||
///
|
||||
/// <ol>
|
||||
/// <li>@ref RestDocumentRead "GET /document/@FA{document-handle}"</li>
|
||||
/// <li>@ref RestDocumentCreate "POST /document?collection=@FA{collection-identifier}"</li>
|
||||
/// <li>@ref RestDocumentUpdate "PUT /document/@FA{document-handle}"</li>
|
||||
/// <li>@ref RestDocumentDelete "DELETE /document/@FA{document-handle}"</li>
|
||||
/// <li>@ref RestDocumentHead "HEAD /document/@FA{document-handle}"</li>
|
||||
/// <li>@ref RestDocumentReadAll "GET /document?collection=@FA{collection-identifier}"</li>
|
||||
/// <li>@ref RestDocumentRead "GET /document/document-handle"</li>
|
||||
/// <li>@ref RestDocumentCreate "POST /document?collection=collection-identifier"</li>
|
||||
/// <li>@ref RestDocumentUpdate "PUT /document/document-handle"</li>
|
||||
/// <li>@ref RestDocumentDelete "DELETE /document/document-handle"</li>
|
||||
/// <li>@ref RestDocumentHead "HEAD /document/document-handle"</li>
|
||||
/// <li>@ref RestDocumentReadAll "GET /document?collection=collection-identifier"</li>
|
||||
/// </ol>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
///
|
||||
/// <ol>
|
||||
/// <li>@ref ShellCollectionRead "db._collection(collection-identifier)"</li>
|
||||
/// <li>@ref ShellCollectionCreate "db._create(collection-name, properties)"</li>
|
||||
/// <li>@ref ShellCollectionReadAll "db._collections()"</li>
|
||||
/// <li>@ref ShellCollectionReadShortCut "db.collection-name"</li>
|
||||
/// <li>@ref ShellCollectionProperties "collection.properties()"</li>
|
||||
/// </ol>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -106,6 +110,22 @@
|
|||
/// @copydetails JS_CollectionVocBase
|
||||
/// <hr>
|
||||
///
|
||||
/// @anchor ShellCollectionCreate
|
||||
/// @copydetails JS_CreateVocBase
|
||||
/// <hr>
|
||||
///
|
||||
/// @anchor ShellCollectionReadAll
|
||||
/// @copydetails JS_CollectionsVocBase
|
||||
/// <hr>
|
||||
///
|
||||
/// @anchor ShellCollectionReadShortCut
|
||||
/// @copydetails MapGetVocBase
|
||||
/// <hr>
|
||||
///
|
||||
/// @anchor ShellCollectionProperties
|
||||
/// @copydetails JS_PropertiesVocbaseCol
|
||||
/// <hr>
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Local Variables:
|
||||
|
|
|
@ -159,7 +159,7 @@ static char* CompletionGenerator (char const* text, int state) {
|
|||
v8::String::Utf8Value str(v);
|
||||
char const* s = *str;
|
||||
|
||||
if (s != 0) {
|
||||
if (s != 0 && *s) {
|
||||
string suffix = (current->Get(v)->IsFunction()) ? "()" : "";
|
||||
string name = path + s + suffix;
|
||||
|
||||
|
|
|
@ -4378,21 +4378,28 @@ static v8::Handle<v8::Value> JS_NameVocbaseCol (v8::Arguments const& argv) {
|
|||
///
|
||||
/// - @LIT{waitForSync}: If @LIT{true} creating a document will only return
|
||||
/// after the data was synced to disk.
|
||||
///
|
||||
/// - @LIT{journalSize} : The size of the journal in bytes.
|
||||
///
|
||||
/// @FUN{properties(@FA{properties-array})}
|
||||
/// @FUN{properties(@FA{properties})}
|
||||
///
|
||||
/// Changes the collection properties.
|
||||
/// Changes the collection properties. @FA{properties} must be a object with
|
||||
/// one or more of the following attribute(s):
|
||||
///
|
||||
/// - @LIT{waitForSync}: If @LIT{true} creating a document will only return
|
||||
/// after the data was synced to disk.
|
||||
///
|
||||
/// Note that it is not possible to change the journal size after creation.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// Read all properties
|
||||
///
|
||||
/// @verbinclude admin1
|
||||
/// @verbinclude shell_collection-properties
|
||||
///
|
||||
/// Change a property
|
||||
///
|
||||
/// @verbinclude admin2
|
||||
/// @verbinclude shell_collection-properties-change
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_PropertiesVocbaseCol (v8::Arguments const& argv) {
|
||||
|
@ -4827,6 +4834,16 @@ static v8::Handle<v8::Value> JS_SaveEdgesCol (v8::Arguments const& argv) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief selects a collection from the vocbase
|
||||
///
|
||||
/// @FUN{db.@FA{collection-name}}
|
||||
///
|
||||
/// Returns the collection with the given @FA{collection-name}. If no such
|
||||
/// collection exists, create a collection named @FA{collection-name} with the
|
||||
/// default properties.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// @verbinclude shell_read-collection-short-cut
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> MapGetVocBase (v8::Local<v8::String> name,
|
||||
|
@ -4843,7 +4860,7 @@ static v8::Handle<v8::Value> MapGetVocBase (v8::Local<v8::String> name,
|
|||
string key = TRI_ObjectToString(name);
|
||||
|
||||
if (key == "") {
|
||||
return scope.Close(v8::ThrowException(v8::String::New("name must not be empty")));
|
||||
return scope.Close(v8::ThrowException(CreateErrorObject(TRI_ERROR_AVOCADO_ILLEGAL_NAME, "name must not be empty")));
|
||||
}
|
||||
|
||||
if ( key == "toString"
|
||||
|
@ -4947,6 +4964,14 @@ static v8::Handle<v8::Value> JS_CollectionVocBase (v8::Arguments const& argv) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns all collections
|
||||
///
|
||||
/// @FUN{db._collections()}
|
||||
///
|
||||
/// Returns all collections of the given database.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// @verbinclude shell_read-collection-all
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_CollectionsVocBase (v8::Arguments const& argv) {
|
||||
|
@ -5004,6 +5029,34 @@ static v8::Handle<v8::Value> JS_CompletionsVocBase (v8::Arguments const& argv) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a new collection
|
||||
///
|
||||
/// @FUN{db._create(@FA{collection-name})}
|
||||
///
|
||||
/// Creates a new collection named @FA{collection-name}. If the collection name
|
||||
/// already exists, than an error is thrown. The default value for
|
||||
/// @LIT{waitForSync} is @LIT{false}.
|
||||
///
|
||||
/// @FUN{db._create(@FA{collection-name}, @FA{properties})}
|
||||
///
|
||||
/// @FA{properties} must be an object, with the following attribues:
|
||||
///
|
||||
/// - @LIT{waitForSync} (optional, default @LIT{false}): If @LIT{true} creating
|
||||
/// a document will only return after the data was synced to disk.
|
||||
///
|
||||
/// - @LIT{journalSize} (optional, default is a @ref CommandLineAvocado
|
||||
/// "configuration parameter"): The maximal size of
|
||||
/// a journal or datafile. Note that this also limits the maximal
|
||||
/// size of a single object. Must be at least 1MB.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// With defaults:
|
||||
///
|
||||
/// @verbinclude shell_create-collection
|
||||
///
|
||||
/// With properties:
|
||||
///
|
||||
/// @verbinclude shell_create-collection-properties
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_CreateVocBase (v8::Arguments const& argv) {
|
||||
|
@ -5019,7 +5072,7 @@ static v8::Handle<v8::Value> JS_CreateVocBase (v8::Arguments const& argv) {
|
|||
if (argv.Length() < 1) {
|
||||
return scope.Close(v8::ThrowException(
|
||||
CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
|
||||
"usage: _create(<name>, <parameters>)")));
|
||||
"usage: _create(<name>, <properties>)")));
|
||||
}
|
||||
|
||||
// extract the name
|
||||
|
@ -5030,7 +5083,7 @@ static v8::Handle<v8::Value> JS_CreateVocBase (v8::Arguments const& argv) {
|
|||
|
||||
if (2 <= argv.Length()) {
|
||||
if (! argv[1]->IsObject()) {
|
||||
return scope.Close(v8::ThrowException(CreateErrorObject(TRI_ERROR_BAD_PARAMETER, "<parameters> must be an object")));
|
||||
return scope.Close(v8::ThrowException(CreateErrorObject(TRI_ERROR_BAD_PARAMETER, "<properties> must be an object")));
|
||||
}
|
||||
|
||||
v8::Handle<v8::Object> p = argv[1]->ToObject();
|
||||
|
@ -5043,7 +5096,7 @@ static v8::Handle<v8::Value> JS_CreateVocBase (v8::Arguments const& argv) {
|
|||
if (s < TRI_JOURNAL_MINIMAL_SIZE) {
|
||||
return scope.Close(v8::ThrowException(
|
||||
CreateErrorObject(TRI_ERROR_BAD_PARAMETER,
|
||||
"<parameters>.journalSize too small")));
|
||||
"<properties>.journalSize too small")));
|
||||
}
|
||||
|
||||
TRI_InitParameterCollection(¶meter, name.c_str(), (TRI_voc_size_t) s);
|
||||
|
@ -5228,7 +5281,7 @@ static v8::Handle<v8::Value> MapGetEdges (v8::Local<v8::String> name,
|
|||
string key = TRI_ObjectToString(name);
|
||||
|
||||
if (key == "") {
|
||||
return scope.Close(v8::ThrowException(v8::String::New("name must not be empty")));
|
||||
return scope.Close(v8::ThrowException(CreateErrorObject(TRI_ERROR_AVOCADO_ILLEGAL_NAME, "name must not be empty")));
|
||||
}
|
||||
|
||||
if ( key == "toString"
|
||||
|
@ -5362,7 +5415,7 @@ static v8::Handle<v8::Value> MapGetShapedJson (v8::Local<v8::String> name,
|
|||
string key = TRI_ObjectToString(name);
|
||||
|
||||
if (key == "") {
|
||||
return scope.Close(v8::ThrowException(v8::String::New("name must not be empty")));
|
||||
return scope.Close(v8::ThrowException(CreateErrorObject(TRI_ERROR_AVOCADO_ILLEGAL_NAME, "name must not be empty")));
|
||||
}
|
||||
|
||||
if (key[0] == '_') {
|
||||
|
|
|
@ -366,7 +366,7 @@ void TRI_InitParameterCollection (TRI_col_parameter_t* parameter,
|
|||
|
||||
parameter->_type = TRI_COL_TYPE_SIMPLE_DOCUMENT;
|
||||
|
||||
parameter->_waitForSync = true;
|
||||
parameter->_waitForSync = false;
|
||||
|
||||
parameter->_maximalSize = (maximalSize / PageSize) * PageSize;
|
||||
|
||||
|
|
|
@ -590,6 +590,13 @@ static TRI_vocbase_col_t* BearCollectionVocBase (TRI_vocbase_t* vocbase, char co
|
|||
// create a new one
|
||||
// .............................................................................
|
||||
|
||||
if (*name == '\0') {
|
||||
TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase);
|
||||
|
||||
TRI_set_errno(TRI_ERROR_AVOCADO_ILLEGAL_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// check that the name does not contain any strange characters
|
||||
wrong = TRI_IsAllowedCollectionName(name);
|
||||
|
||||
|
@ -1233,6 +1240,13 @@ TRI_vocbase_col_t* TRI_CreateCollectionVocBase (TRI_vocbase_t* vocbase, TRI_col_
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (*name == '\0') {
|
||||
TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase);
|
||||
|
||||
TRI_set_errno(TRI_ERROR_AVOCADO_ILLEGAL_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// check that the name does not contain any strange characters
|
||||
wrong = TRI_IsAllowedCollectionName(name);
|
||||
|
||||
|
@ -1482,6 +1496,10 @@ int TRI_RenameCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t* coll
|
|||
}
|
||||
|
||||
// check name conventions
|
||||
if (*newName == '\0') {
|
||||
return TRI_set_errno(TRI_ERROR_AVOCADO_ILLEGAL_NAME);
|
||||
}
|
||||
|
||||
wrong = TRI_IsAllowedCollectionName(newName);
|
||||
|
||||
if (wrong != 0) {
|
||||
|
|
|
@ -104,15 +104,16 @@ function CollectionRepresentation (collection, showProperties, showCount, showFi
|
|||
/// Creates an new collection with a given name. The request must contain an
|
||||
/// object with the following attributes.
|
||||
///
|
||||
/// @LIT{name}: The name of the collection.
|
||||
/// - @LIT{name}: The name of the collection.
|
||||
///
|
||||
/// @LIT{waitForSync} (optional, default: false): If @LIT{true} then the data
|
||||
/// is synchronised to disk before returning from a create or update of an
|
||||
/// document.
|
||||
/// - @LIT{waitForSync} (optional, default: false): If @LIT{true} then
|
||||
/// the data is synchronised to disk before returning from a create or
|
||||
/// update of an document.
|
||||
///
|
||||
/// @LIT{journalSize} (optional, default 32MB): The maximal size of a
|
||||
/// journal or datafile. Note that this also limits the maximal size
|
||||
/// of a single object. Must be at least 1MB.
|
||||
/// - @LIT{journalSize} (optional, default is a @ref
|
||||
/// CommandLineAvocado "configuration parameter"): The maximal size of
|
||||
/// a journal or datafile. Note that this also limits the maximal
|
||||
/// size of a single object. Must be at least 1MB.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
|
@ -211,17 +212,16 @@ function GET_api_collections (req, res) {
|
|||
/// The result is an objects describing the collection with the following
|
||||
/// attributes:
|
||||
///
|
||||
/// @LIT{id}: The identifier of the collection.
|
||||
/// - @LIT{id}: The identifier of the collection.
|
||||
///
|
||||
/// @LIT{name}: The name of the collection.
|
||||
/// - @LIT{name}: The name of the collection.
|
||||
///
|
||||
/// @LIT{status}: The status of the collection as number.
|
||||
///
|
||||
/// - 1: new born collection
|
||||
/// - 2: unloaded
|
||||
/// - 3: loaded
|
||||
/// - 4: in the process of being unloaded
|
||||
/// - 5: deleted
|
||||
/// - @LIT{status}: The status of the collection as number.
|
||||
/// - 1: new born collection
|
||||
/// - 2: unloaded
|
||||
/// - 3: loaded
|
||||
/// - 4: in the process of being unloaded
|
||||
/// - 5: deleted
|
||||
///
|
||||
/// Every other status indicates a corrupted collection.
|
||||
///
|
||||
|
@ -242,10 +242,10 @@ function GET_api_collections (req, res) {
|
|||
/// @LIT{waitForSync} and the @LIT{journalSize} properties. This is
|
||||
/// achieved by forcing a load of the underlying collection.
|
||||
///
|
||||
/// @LIT{waitForSync}: If @LIT{true} then creating or changing a document will
|
||||
/// wait until the data has been synchronised to disk.
|
||||
/// - @LIT{waitForSync}: If @LIT{true} then creating or changing a
|
||||
/// document will wait until the data has been synchronised to disk.
|
||||
///
|
||||
/// @LIT{journalSize}: The maximal size of a journal / datafile.
|
||||
/// - @LIT{journalSize}: The maximal size of a journal / datafile.
|
||||
///
|
||||
/// @REST{GET /_api/collection/@FA{collection-identifier}/count}
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
@ -253,7 +253,7 @@ function GET_api_collections (req, res) {
|
|||
/// In addition to the above, the result also contains the number of documents.
|
||||
/// Note that this will always load the collection into memory.
|
||||
///
|
||||
/// @LIT{count}: The number of documents inside the collection.
|
||||
/// - @LIT{count}: The number of documents inside the collection.
|
||||
///
|
||||
/// @REST{GET /_api/collection/@FA{collection-identifier}/figures}
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
@ -262,21 +262,21 @@ function GET_api_collections (req, res) {
|
|||
/// and additional statistical information about the collection. Note that this
|
||||
/// will always load the collection into memory.
|
||||
///
|
||||
/// @LIT{count}: The number of documents inside the collection.
|
||||
/// - @LIT{count}: The number of documents inside the collection.
|
||||
///
|
||||
/// @LIT{figures.alive.count}: The number of living documents.
|
||||
/// - @LIT{figures.alive.count}: The number of living documents.
|
||||
///
|
||||
/// @LIT{figures.alive.size}: The total size in bytes used by all living
|
||||
/// documents.
|
||||
/// - @LIT{figures.alive.size}: The total size in bytes used by all
|
||||
/// living documents.
|
||||
///
|
||||
/// @LIT{figures.dead.count}: The number of dead documents.
|
||||
/// - @LIT{figures.dead.count}: The number of dead documents.
|
||||
///
|
||||
/// @LIT{figures.dead.size}: The total size in bytes used by all dead
|
||||
/// documents.
|
||||
/// - @LIT{figures.dead.size}: The total size in bytes used by all
|
||||
/// dead documents.
|
||||
///
|
||||
/// @LIT{figures.datafile.count}: The number of active datafiles.
|
||||
/// - @LIT{figures.datafile.count}: The number of active datafiles.
|
||||
///
|
||||
/// @LIT{journalSize}: The maximal size of the journal in bytes.
|
||||
/// - @LIT{journalSize}: The maximal size of the journal in bytes.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
/////////////
|
||||
|
@ -393,13 +393,13 @@ function GET_api_collection (req, res) {
|
|||
///
|
||||
/// Loads a collection into memory. On success an object with the following
|
||||
///
|
||||
/// @LIT{id}: The identifier of the collection.
|
||||
/// - @LIT{id}: The identifier of the collection.
|
||||
///
|
||||
/// @LIT{name}: The name of the collection.
|
||||
/// - @LIT{name}: The name of the collection.
|
||||
///
|
||||
/// @LIT{count}: The number of documents inside the collection.
|
||||
/// - @LIT{count}: The number of documents inside the collection.
|
||||
///
|
||||
/// @LIT{status}: The status of the collection as number.
|
||||
/// - @LIT{status}: The status of the collection as number.
|
||||
///
|
||||
/// If the @FA{collection-identifier} is missing, then a @LIT{HTTP 400} is
|
||||
/// returned. If the @FA{collection-identifier} is unknown, then a @LIT{HTTP
|
||||
|
@ -434,11 +434,11 @@ function PUT_api_collection_load (req, res, collection) {
|
|||
/// You can use the collection afterwards; in which case it will be loaded into
|
||||
/// memory, again. On success an object with the following
|
||||
///
|
||||
/// @LIT{id}: The identifier of the collection.
|
||||
/// - @LIT{id}: The identifier of the collection.
|
||||
///
|
||||
/// @LIT{name}: The name of the collection.
|
||||
/// - @LIT{name}: The name of the collection.
|
||||
///
|
||||
/// @LIT{status}: The status of the collection as number.
|
||||
/// - @LIT{status}: The status of the collection as number.
|
||||
///
|
||||
/// If the @FA{collection-identifier} is missing, then a @LIT{HTTP 400} is
|
||||
/// returned. If the @FA{collection-identifier} is unknown, then a @LIT{HTTP
|
||||
|
@ -498,16 +498,16 @@ function PUT_api_collection_truncate (req, res, collection) {
|
|||
/// Changes the properties of a collection. Expects an object with the
|
||||
/// attribute(s)
|
||||
///
|
||||
/// @LIT{waitForSync}: If @LIT{true} then creating or changing a document will
|
||||
/// wait until the data has been synchronised to disk.
|
||||
/// - @LIT{waitForSync}: If @LIT{true} then creating or changing a
|
||||
/// document will wait until the data has been synchronised to disk.
|
||||
///
|
||||
/// If returns an object with the attributes
|
||||
///
|
||||
/// @LIT{id}: The identifier of the collection.
|
||||
/// - @LIT{id}: The identifier of the collection.
|
||||
///
|
||||
/// @LIT{name}: The name of the collection.
|
||||
/// - @LIT{name}: The name of the collection.
|
||||
///
|
||||
/// @LIT{waitForSync}: The new value.
|
||||
/// - @LIT{waitForSync}: The new value.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
|
@ -544,13 +544,13 @@ function PUT_api_collection_properties (req, res, collection) {
|
|||
///
|
||||
/// Renames a collection. Expects an object with the attribute(s)
|
||||
///
|
||||
/// @LIT{name}: The new name.
|
||||
/// - @LIT{name}: The new name.
|
||||
///
|
||||
/// If returns an object with the attributes
|
||||
///
|
||||
/// @LIT{id}: The identifier of the collection.
|
||||
/// - @LIT{id}: The identifier of the collection.
|
||||
///
|
||||
/// @LIT{name}: The new name of the collection.
|
||||
/// - @LIT{name}: The new name of the collection.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
|
@ -644,9 +644,9 @@ function PUT_api_collection (req, res) {
|
|||
/// If the collection was successfully deleted then, an object is returned with
|
||||
/// the following attributes:
|
||||
///
|
||||
/// @LIT{error}: @LIT{false}
|
||||
/// - @LIT{error}: @LIT{false}
|
||||
///
|
||||
/// @LIT{id}: The identifier of the deleted collection.
|
||||
/// - @LIT{id}: The identifier of the deleted collection.
|
||||
///
|
||||
/// If the @FA{collection-identifier} is missing, then a @LIT{HTTP 400} is
|
||||
/// returned. If the @FA{collection-identifier} is unknown, then a @LIT{HTTP
|
||||
|
|
|
@ -101,9 +101,9 @@ function GET_api_indexes (req, res) {
|
|||
/// The result is an objects describing the index with the following
|
||||
/// attributes:
|
||||
///
|
||||
/// @LIT{id}: The identifier of the collection.
|
||||
/// - @LIT{id}: The identifier of the collection.
|
||||
///
|
||||
/// @LIT{type}: The type of the collection.
|
||||
/// - @LIT{type}: The type of the collection.
|
||||
///
|
||||
/// All other attributes are type-dependent.
|
||||
///
|
||||
|
|
|
@ -44,28 +44,29 @@ var actions = require("actions");
|
|||
///
|
||||
/// The call returns an object with the following attributes:
|
||||
///
|
||||
/// @LIT{system.userTime}: Amount of time that this process has been scheduled
|
||||
/// in user mode, measured in clock ticks divided by sysconf(_SC_CLK_TCK) aka
|
||||
/// seconds.
|
||||
/// - @LIT{system.userTime}: Amount of time that this process has been
|
||||
/// scheduled in user mode, measured in clock ticks divided by
|
||||
/// sysconf(_SC_CLK_TCK) aka seconds.
|
||||
///
|
||||
/// @LIT{system.systemTime}: mount of time that this process has been scheduled
|
||||
/// in kernel mode, measured in clock ticks divided by sysconf(_SC_CLK_TCK) aka
|
||||
/// seconds.
|
||||
/// - @LIT{system.systemTime}: mount of time that this process has
|
||||
/// been scheduled in kernel mode, measured in clock ticks divided by
|
||||
/// sysconf(_SC_CLK_TCK) aka seconds.
|
||||
///
|
||||
/// @LIT{system.numberOfThreads}: Number of threads in this process.
|
||||
/// - @LIT{system.numberOfThreads}: Number of threads in this process.
|
||||
///
|
||||
/// @LIT{system.residentSize}: Resident Set Size: number of pages the process
|
||||
/// has in real memory. This is just the pages which count toward text, data,
|
||||
/// or stack space. This does not include pages which have not been
|
||||
/// demand-loaded in, or which are swapped out.
|
||||
/// - @LIT{system.residentSize}: Resident Set Size: number of pages
|
||||
/// the process has in real memory. This is just the pages which
|
||||
/// count toward text, data, or stack space. This does not include
|
||||
/// pages which have not been demand-loaded in, or which are swapped
|
||||
/// out.
|
||||
///
|
||||
/// @LIT{system.virtualSize}: Virtual memory size in bytes.
|
||||
/// - @LIT{system.virtualSize}: Virtual memory size in bytes.
|
||||
///
|
||||
/// @LIT{system.minorPageFaults}: The number of minor faults the process has
|
||||
/// made which have not required loading a memory page from disk.
|
||||
/// - @LIT{system.minorPageFaults}: The number of minor faults the process has
|
||||
/// made which have not required loading a memory page from disk.
|
||||
///
|
||||
/// @LIT{system.majorPageFaults}: The number of major faults the process has
|
||||
/// made which have required loading a memory page from disk.
|
||||
/// - @LIT{system.majorPageFaults}: The number of major faults the process has
|
||||
/// made which have required loading a memory page from disk.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
actions.defineHttp({
|
||||
|
|
|
@ -425,6 +425,7 @@ function RunCommandLineTests () {
|
|||
}
|
||||
catch (err) {
|
||||
print("cannot run test file '" + file + "': " + err);
|
||||
print(err.stack);
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,291 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test the collection interface
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var jsunity = require("jsunity");
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- collection methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test suite: error handling
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function collectionSuiteErrorHandling () {
|
||||
var ERRORS = require("internal").errors;
|
||||
|
||||
return {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief bad name (underscore)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testErrorHandlingBadNameUnderscore : function () {
|
||||
try {
|
||||
db._create("_illegal");
|
||||
}
|
||||
catch (err) {
|
||||
assertEqual(ERRORS.ERROR_AVOCADO_ILLEGAL_NAME.code, err.errorNum);
|
||||
}
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief bad name (empty)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testErrorHandlingBadNameEmpty : function () {
|
||||
try {
|
||||
db._create("");
|
||||
}
|
||||
catch (err) {
|
||||
assertEqual(ERRORS.ERROR_AVOCADO_ILLEGAL_NAME.code, err.errorNum);
|
||||
}
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief bad name (number)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testErrorHandlingBadNameNumber : function () {
|
||||
try {
|
||||
db._create("12345");
|
||||
}
|
||||
catch (err) {
|
||||
assertEqual(ERRORS.ERROR_AVOCADO_ILLEGAL_NAME.code, err.errorNum);
|
||||
}
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief bad name (underscore) (short-cut)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testErrorHandlingBadNameUnderscoreShortCut : function () {
|
||||
try {
|
||||
db["_illegal"];
|
||||
}
|
||||
catch (err) {
|
||||
assertEqual(ERRORS.ERROR_AVOCADO_ILLEGAL_NAME.code, err.errorNum);
|
||||
}
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief bad name (empty) (short-cut)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testErrorHandlingBadNameEmptyShortCut : function () {
|
||||
try {
|
||||
db[""];
|
||||
}
|
||||
catch (err) {
|
||||
assertEqual(ERRORS.ERROR_AVOCADO_ILLEGAL_NAME.code, err.errorNum);
|
||||
}
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief bad name (number) (short-cut)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testErrorHandlingBadNameNumberShortCut : function () {
|
||||
try {
|
||||
db["12345"];
|
||||
}
|
||||
catch (err) {
|
||||
assertEqual(ERRORS.ERROR_AVOCADO_ILLEGAL_NAME.code, err.errorNum);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test suite: collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function collectionSuite () {
|
||||
var ERRORS = require("internal").errors;
|
||||
|
||||
return {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read by name
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testReadingByName : function () {
|
||||
var cn = "example";
|
||||
|
||||
db._drop(cn);
|
||||
var c1 = db._create(cn);
|
||||
|
||||
assertTypeOf("number", c1._id);
|
||||
assertEqual(cn, c1.name());
|
||||
assertTypeOf("number", c1.status());
|
||||
|
||||
var c2 = db._collection(cn);
|
||||
|
||||
assertEqual(c1._id, c2._id);
|
||||
assertEqual(c1.name(), c2.name());
|
||||
assertEqual(c1.status(), c2.status());
|
||||
|
||||
db._drop(cn);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read by identifier
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testReadingByIdentifier : function () {
|
||||
var cn = "example";
|
||||
|
||||
db._drop(cn);
|
||||
var c1 = db._create(cn);
|
||||
|
||||
assertTypeOf("number", c1._id);
|
||||
assertEqual(cn, c1.name());
|
||||
assertTypeOf("number", c1.status());
|
||||
|
||||
var c2 = db._collection(c1._id);
|
||||
|
||||
assertEqual(c1._id, c2._id);
|
||||
assertEqual(c1.name(), c2.name());
|
||||
assertEqual(c1.status(), c2.status());
|
||||
|
||||
db._drop(cn);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read by name (short-cut)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testReadingByNameShortCut : function () {
|
||||
var cn = "example";
|
||||
|
||||
db._drop(cn);
|
||||
var c1 = db._create(cn);
|
||||
|
||||
assertTypeOf("number", c1._id);
|
||||
assertEqual(cn, c1.name());
|
||||
assertTypeOf("number", c1.status());
|
||||
|
||||
var c2 = db[cn];
|
||||
|
||||
assertEqual(c1._id, c2._id);
|
||||
assertEqual(c1.name(), c2.name());
|
||||
assertEqual(c1.status(), c2.status());
|
||||
|
||||
db._drop(cn);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read all
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testReadingAll : function () {
|
||||
var cn = "example";
|
||||
|
||||
db._drop(cn);
|
||||
var c1 = db._create(cn);
|
||||
|
||||
assertTypeOf("number", c1._id);
|
||||
assertEqual(cn, c1.name());
|
||||
assertTypeOf("number", c1.status());
|
||||
|
||||
var l = db._collections();
|
||||
|
||||
assertNotEqual(0, l.length);
|
||||
|
||||
db._drop(cn);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creating with defaults
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testCreatingDefaults : function () {
|
||||
var cn = "example";
|
||||
|
||||
db._drop(cn);
|
||||
var c1 = db._create(cn);
|
||||
|
||||
assertTypeOf("number", c1._id);
|
||||
assertEqual(cn, c1.name());
|
||||
assertTypeOf("number", c1.status());
|
||||
|
||||
var p = c1.properties();
|
||||
|
||||
assertEqual(false, p.waitForSync);
|
||||
|
||||
db._drop(cn);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creating with properties
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testCreatingProperties : function () {
|
||||
var cn = "example";
|
||||
|
||||
db._drop(cn);
|
||||
var c1 = db._create(cn, { waitForSync : true, journalSize : 1024 * 1024 });
|
||||
|
||||
assertTypeOf("number", c1._id);
|
||||
assertEqual(cn, c1.name());
|
||||
assertTypeOf("number", c1.status());
|
||||
|
||||
var p = c1.properties();
|
||||
|
||||
assertEqual(true, p.waitForSync);
|
||||
|
||||
if (p.journalSize < 1024 * 1024) {
|
||||
fail();
|
||||
}
|
||||
|
||||
if (1024 * 1025 < p.journalSize) {
|
||||
fail();
|
||||
}
|
||||
|
||||
db._drop(cn);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- main
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief executes the test suites
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
jsunity.run(collectionSuiteErrorHandling);
|
||||
jsunity.run(collectionSuite);
|
||||
|
||||
return jsunity.done();
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
|
||||
// End:
|
||||
|
|
@ -35,7 +35,7 @@ var jsunity = require("jsunity");
|
|||
/// @brief test suite: error handling
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function readCollectionDocumentSuiteErrorHandling () {
|
||||
function collectionDocumentSuiteErrorHandling () {
|
||||
var cn = "UnitTestsCollectionBasics";
|
||||
var ERRORS = require("internal").errors;
|
||||
var collection = null;
|
||||
|
@ -107,7 +107,7 @@ function readCollectionDocumentSuiteErrorHandling () {
|
|||
/// @brief test suite: normal operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function readCollectionDocumentSuiteReadDocument () {
|
||||
function collectionDocumentSuiteReadDocument () {
|
||||
var cn = "UnitTestsCollectionBasics";
|
||||
var ERRORS = require("internal").errors;
|
||||
var collection = null;
|
||||
|
@ -274,7 +274,7 @@ function readCollectionDocumentSuiteReadDocument () {
|
|||
/// @brief test suite: error handling
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function readDocumentSuiteErrorHandling () {
|
||||
function documentSuiteErrorHandling () {
|
||||
var cn = "UnitTestsCollectionBasics";
|
||||
var ERRORS = require("internal").errors;
|
||||
|
||||
|
@ -318,7 +318,7 @@ function readDocumentSuiteErrorHandling () {
|
|||
/// @brief test suite: normal operations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function readDocumentSuiteReadDocument () {
|
||||
function documentSuiteReadDocument () {
|
||||
var cn = "UnitTestsCollectionBasics";
|
||||
var ERRORS = require("internal").errors;
|
||||
var collection = null;
|
||||
|
@ -474,11 +474,11 @@ function readDocumentSuiteReadDocument () {
|
|||
/// @brief executes the test suites
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
jsunity.run(readCollectionDocumentSuiteErrorHandling);
|
||||
jsunity.run(readCollectionDocumentSuiteReadDocument);
|
||||
jsunity.run(collectionDocumentSuiteErrorHandling);
|
||||
jsunity.run(collectionDocumentSuiteReadDocument);
|
||||
|
||||
jsunity.run(readDocumentSuiteErrorHandling);
|
||||
jsunity.run(readDocumentSuiteReadDocument);
|
||||
jsunity.run(documentSuiteErrorHandling);
|
||||
jsunity.run(documentSuiteReadDocument);
|
||||
|
||||
return jsunity.done();
|
||||
|
Loading…
Reference in New Issue