====== BigObject PolyDB::Collection ====== //from application [[..:common|common]]//\\ \\ Represents a collection in PolyDB ===== Methods ===== ==== Database Access ==== Core methods for connecting to the database and retrieving metadata. ---- {{anchor:get_schema:}} ? **''get_schema()''** :: Get a JSON validation schema for objects stored in the collection ? Returns: :''[[..:core:Schema |Schema]]'' ---- ==== Database Collection Administration ==== Methods to manipulate a given collection. ---- {{anchor:add_index:}} ? **''add_index(HASH index)''** :: Add an index to a collection ? Parameters: :: ''HASH'' ''index'': definition ? Options: : :: ''[[..:common#String |String]]'' ''name'': index name ---- {{anchor:add_index_from_property:}} ? **''add_index_from_property([[..:common#String |String]] property)''** :: Add an index to a collection for a property ? Parameters: :: ''[[..:common#String |String]]'' ''property'' ? Options: : :: ''[[..:common#Bool |Bool]]'' ''ascending'': sort documents ascending wrt the property, default true ---- {{anchor:add_indices:}} ? **''add_indices(ARRAY index)''** :: Add many indices to a collection ? Parameters: :: ''ARRAY'' ''index'': definitions ? Options: : :: ''[[..:common#String |String]]'' ''name'': index name ---- {{anchor:add_indices_from_property:}} ? **''add_indices_from_property(ARRAY property)''** :: Add an index to a collection for a property ? Parameters: :: ''ARRAY'' ''property'': names ? Options: : :: ''[[..:common#Bool |Bool]]'' ''ascending'': sort documents ascending wrt the property, default true ---- {{anchor:indices:}} ? **''indices''** :: list all indices defined for a collection ---- {{anchor:insert:}} ? **''insert([[..:core:Core_BigObject |Core::BigObject]] one)''** :: Insert one or more objects into a given collection ? Parameters: :: ''[[..:core:Core_BigObject |Core::BigObject]]'' ''one'': or more objects to be inserted to be inserted into the database, or a filename containing an object or an array of objects ? Options: : option list ''[[..:common#insert_options |insert_options]]'' ? Returns: :''[[..:common#Int |Int]]'' ---- {{anchor:remove:}} ? **''remove([[..:common#String |String]] id)''** :: Remove one object from a collection identified by its id ? Parameters: :: ''[[..:common#String |String]]'' ''id'': the id of the object to remove ---- {{anchor:remove_all:}} ? **''remove_all''** :: Remove all objects from a collection ---- {{anchor:set_collection_doc:}} ? **''set_collection_doc(HASH doc)''** :: Set documentation for a collection ? Parameters: :: ''HASH'' ''doc'': the documentation ? Options: : option list ''[[..:common#doc_options |doc_options]]'' ---- {{anchor:set_info:}} ? **''set_info(HASH info)''** :: set the info for a new collection ? Parameters: :: ''HASH'' ''info'': the info document ? Options: : option list ''[[..:common#info_options |info_options]]'' ---- {{anchor:set_schema:}} ? **''set_schema(HASH schema)''** :: set the schema for a new collection ? Parameters: :: ''HASH'' ''schema'': the schema document ? Options: : option list ''[[..:common#schema_options |schema_options]]'' ---- ==== Database Query Operations ==== Methods that provide query operations for the database or manipulate the result stream of a query. ---- {{anchor:count:}} ? **''count(HASH query)''** :: Return the number of objects satisfying the given search criteria. ? Parameters: :: ''HASH'' ''query'': search criteria written in Mongo query language ---- {{anchor:count_distinct:}} ? **''count_distinct(HASH query, [[..:common#String |String]] property)''** :: Count the distinct property values in objects satisfying the given search criteria. ? Parameters: :: ''HASH'' ''query'': search criteria for objects to be inspected, written in Mongo query language an empty hash map will collect property values from all objects in this collection :: ''[[..:common#String |String]]'' ''property'': name of the property of interest ---- {{anchor:distinct:}} ? **''distinct(HASH query, [[..:common#String |String]] property)''** :: Retrieve a list of distinct values of a given property. The values are returned in arbitrary order. ? Parameters: :: ''HASH'' ''query'': search criteria for objects to be inspected, written in Mongo query language an empty hash map will collect property values from all objects in this collection :: ''[[..:common#String |String]]'' ''property'': name of the property of interest ? Returns: :''ARRAY'' ---- {{anchor:find:}} ? **''find(HASH query)''** :: Retrieve all objects satisfying the given search criteria ? Parameters: :: ''HASH'' ''query'': search criteria written in Mongo query language an empty hash map will retrieve all objects in this collection ? Options: : option list ''[[..:common#cursor_options |cursor_options]]'' ? Returns: :''[[..:common:PolyDB_Cursor |PolyDB::Cursor]]'' ---- {{anchor:find_one:}} ? **''find_one(HASH query)''** :: Retrieve the first object satisfying the given search criteria. ? Parameters: :: ''HASH'' ''query'': search criteria written in Mongo query language an empty hash map will retrieve a random object from this collection ? Options: : option list ''[[..:common#query_options |query_options]]'' ? Returns: :''[[..:core:Core_BigObject |Core::BigObject]]'' ----