Functions
Quick Links
Table of Contents
CRUD Functions
- aggregate_cursor_first_page()
- count_query()
- cursor_get_more()
- delete()
- distinct_query()
- find_and_modify()
- find_cursor_first_page()
- insert()
- insert_one()
- list_collections_cursor_first_page()
- list_indexes_cursor_first_page()
- update()
Schema Management Functions
- coll_mod()
- create_collection()
- create_collection_view()
- drop_collection()
- drop_database()
- rename_collection()
- shard_collection()
User Functions
Utility Functions
CRUD Functions
aggregate_cursor_first_page()
Description
This function retrieves the first page of an aggregate cursor.
Syntax
documentdb_api.aggregate_cursor_first_page(database text, commandSpec documentdb_core.bson, cursorId int8 DEFAULT 0)
Parameters
-
database(text): The name of the database. -
commandSpec(documentdb_core.bson): The BSON specification for the command. -
cursorId(int8): The cursor ID, default is 0.
Returns
-
cursorPage(documentdb_core.bson): The BSON document representing the cursor page. -
continuation(documentdb_core.bson): The BSON document representing the continuation. -
persistConnection(bool): Indicates whether to persist the connection. -
cursorId(int8): The cursor ID.
count_query()
Description
This function performs a count query on the specified database.
Syntax
documentdb_api.count_query(database text, countSpec documentdb_core.bson)
Parameters
-
database(text): The name of the database. -
countSpec(documentdb_core.bson): The BSON specification for the count query.
Returns
-
document(documentdb_core.bson): The BSON document representing the count result.
cursor_get_more()
Description
This function retrieves more results from a cursor.
Syntax
documentdb_api.cursor_get_more(database text, getMoreSpec documentdb_core.bson, continuationSpec documentdb_core.bson)
Parameters
-
database(text): The name of the database. -
getMoreSpec(documentdb_core.bson): The BSON specification for getting more results. -
continuationSpec(documentdb_core.bson): The BSON specification for the continuation.
Returns
-
cursorPage(documentdb_core.bson): The BSON document representing the cursor page. -
continuation(documentdb_core.bson): The BSON document representing the continuation.
delete()
Description
This function deletes documents from the specified database.
Syntax
documentdb_api.delete(p_database_name text, p_delete documentdb_core.bson, p_insert_documents documentdb_core.bsonsequence DEFAULT NULL, p_transaction_id text DEFAULT NULL)
Parameters
-
p_database_name(text): The name of the database. -
p_delete(documentdb_core.bson): The BSON specification for the delete operation. -
p_insert_documents(documentdb_core.bsonsequence): The BSON sequence of documents to insert, default is NULL. -
p_transaction_id(text): The transaction ID, default is NULL.
Returns
-
p_result(documentdb_core.bson): The BSON document representing the result. -
p_success(boolean): Indicates whether the operation was successful.
distinct_query()
Description
This function performs a distinct query on the specified database.
Syntax
documentdb_api.distinct_query(database text, distinctSpec documentdb_core.bson)
Parameters
-
database(text): The name of the database. -
distinctSpec(documentdb_core.bson): The BSON specification for the distinct query.
Returns
-
document(documentdb_core.bson): The BSON document representing the distinct result.
find_and_modify()
Description
This function finds and modifies documents in the specified database.
Syntax
documentdb_api.find_and_modify(p_database_name text, p_message documentdb_core.bson, p_transaction_id text DEFAULT NULL)
Parameters
-
p_database_name(text): The name of the database. -
p_message(documentdb_core.bson): The BSON specification for the find and modify operation. -
p_transaction_id(text): The transaction ID, default is NULL.
Returns
-
p_result(documentdb_core.bson): The BSON document representing the result. -
p_success(boolean): Indicates whether the operation was successful.
find_cursor_first_page()
Description
This function retrieves the first page of a find cursor.
Syntax
documentdb_api.find_cursor_first_page(database text, commandSpec documentdb_core.bson, cursorId int8 DEFAULT 0)
Parameters
-
database(text): The name of the database. -
commandSpec(documentdb_core.bson): The BSON specification for the command. -
cursorId(int8): The cursor ID, default is 0.
Returns
-
cursorPage(documentdb_core.bson): The BSON document representing the cursor page. -
continuation(documentdb_core.bson): The BSON document representing the continuation. -
persistConnection(bool): Indicates whether to persist the connection. -
cursorId(int8): The cursor ID.
insert()
Description
This function inserts documents into the specified database.
Syntax
documentdb_api.insert(p_database_name text, p_insert documentdb_core.bson, p_insert_documents documentdb_core.bsonsequence DEFAULT NULL, p_transaction_id text DEFAULT NULL)
Parameters
-
p_database_name(text): The name of the database. -
p_insert(documentdb_core.bson): The BSON specification for the insert operation. -
p_insert_documents(documentdb_core.bsonsequence): The BSON sequence of documents to insert, default is NULL. -
p_transaction_id(text): The transaction ID, default is NULL.
Returns
-
p_result(documentdb_core.bson): The BSON document representing the result. -
p_success(boolean): Indicates whether the operation was successful.
insert_one()
Description
This function inserts a single document into the specified database.
Syntax
documentdb_api.insert_one(p_database_name text, p_collection_name text, p_document documentdb_core.bson, p_transaction_id text DEFAULT NULL)
Parameters
-
p_database_name(text): The name of the database. -
p_collection_name(text): The name of the collection. -
p_document(documentdb_core.bson): The BSON document to insert. -
p_transaction_id(text): The transaction ID, default is NULL.
Returns
- A BSON document representing the insert result.
list_collections_cursor_first_page()
Description
This function retrieves the first page of a list collections cursor.
Syntax
documentdb_api.list_collections_cursor_first_page(database text, commandSpec documentdb_core.bson, cursorId int8 DEFAULT 0)
Parameters
-
database(text): The name of the database. -
commandSpec(documentdb_core.bson): The BSON specification for the command. -
cursorId(int8): The cursor ID, default is 0.
Returns
-
cursorPage(documentdb_core.bson): The BSON document representing the cursor page. -
continuation(documentdb_core.bson): The BSON document representing the continuation. -
persistConnection(bool): Indicates whether to persist the connection. -
cursorId(int8): The cursor ID.
list_indexes_cursor_first_page()
Description
This function retrieves the first page of a list indexes cursor.
Syntax
documentdb_api.list_indexes_cursor_first_page(database text, commandSpec documentdb_core.bson, cursorId int8 DEFAULT 0)
Parameters
-
database(text): The name of the database. -
commandSpec(documentdb_core.bson): The BSON specification for the command. -
cursorId(int8): The cursor ID, default is 0.
Returns
-
cursorPage(documentdb_core.bson): The BSON document representing the cursor page. -
continuation(documentdb_core.bson): The BSON document representing the continuation. -
persistConnection(bool): Indicates whether to persist the connection. -
cursorId(int8): The cursor ID.
update()
Description
This function updates documents in the specified database.
Syntax
documentdb_api.update(p_database_name text, p_update documentdb_core.bson, p_insert_documents documentdb_core.bsonsequence DEFAULT NULL, p_transaction_id text DEFAULT NULL)
Parameters
-
p_database_name(text): The name of the database. -
p_update(documentdb_core.bson): The BSON specification for the update operation. -
p_insert_documents(documentdb_core.bsonsequence): The BSON sequence of documents to insert, default is NULL. -
p_transaction_id(text): The transaction ID, default is NULL.
Returns
-
p_result(documentdb_core.bson): The BSON document representing the result. -
p_success(boolean): Indicates whether the operation was successful.
Schema Management Functions
coll_mod()
Description
This function modifies a collection.
Syntax
documentdb_api.coll_mod(p_database_name text, p_collection_name text, p_spec documentdb_core.bson)
Parameters
-
p_database_name(text): The name of the database. -
p_collection_name(text): The name of the collection. -
p_spec(documentdb_core.bson): The BSON specification for the modification.
Returns
- A BSON document representing the modification result.
create_collection()
Description
This function creates a new collection.
Syntax
documentdb_api.create_collection(p_database_name text, p_collection_name text)
Parameters
-
p_database_name(text): The name of the database. -
p_collection_name(text): The name of the collection.
Returns
- A BSON document representing the creation result.
create_collection_view()
Description
This function creates a new collection view.
Syntax
documentdb_api.create_collection_view(dbname text, createSpec documentdb_core.bson)
Parameters
-
dbname(text): The name of the database. -
createSpec(documentdb_core.bson): The BSON specification for the view creation.
Returns
- A BSON document representing the view creation result.
drop_collection()
Description
This function drops a collection.
Syntax
documentdb_api.drop_collection(p_database_name text, p_collection_name text, p_write_concern documentdb_core.bson DEFAULT null, p_collection_uuid uuid DEFAULT null, p_track_changes bool DEFAULT true)
Parameters
-
p_database_name(text): The name of the database. -
p_collection_name(text): The name of the collection. -
p_write_concern(documentdb_core.bson): The BSON specification for the write concern, default is null. -
p_collection_uuid(uuid): The UUID of the collection, default is null. -
p_track_changes(bool): Indicates whether to track changes, default is true.
Returns
- A BSON document representing the drop result.
drop_database()
Description
This function drops a database.
Syntax
documentdb_api.drop_database(p_database_name text, p_write_concern documentdb_core.bson DEFAULT null)
Parameters
-
p_database_name(text): The name of the database. -
p_write_concern(documentdb_core.bson): The BSON specification for the write concern, default is null.
Returns
- A BSON document representing the drop result.
rename_collection()
Description
This function renames a collection.
Syntax
documentdb_api.rename_collection(p_database_name text, p_collection_name text, p_target_name text, p_drop_target bool DEFAULT false)
Parameters
-
p_database_name(text): The name of the database. -
p_collection_name(text): The name of the collection. -
p_target_name(text): The new name for the collection. -
p_drop_target(bool): Indicates whether to drop the target collection if it exists, default is false.
Returns
- A BSON document representing the rename result.
shard_collection()
Description
This function shards a collection.
Syntax
documentdb_api.shard_collection(p_database_name text, p_collection_name text, p_shard_key documentdb_core.bson, p_is_reshard bool DEFAULT true)
Parameters
-
p_database_name(text): The name of the database. -
p_collection_name(text): The name of the collection. -
p_shard_key(documentdb_core.bson): The BSON specification for the shard key. -
p_is_reshard(bool): Indicates whether to reshard the collection, default is true.
Returns
- A BSON document representing the shard result.
User Functions
create_user()
Description
This function creates a new user.
Syntax
documentdb_api.create_user(p_spec documentdb_core.bson)
Parameters
-
p_spec(documentdb_core.bson): The BSON specification for the user creation.
Returns
- A BSON document representing the created user.
drop_user()
Description
This function drops a user.
Syntax
documentdb_api.drop_user(p_spec documentdb_core.bson)
Parameters
-
p_spec(documentdb_core.bson): The BSON specification for the user drop.
Returns
- A BSON document representing the dropped user.
update_user()
Description
This function updates a user.
Syntax
documentdb_api.update_user(p_spec documentdb_core.bson)
Parameters
-
p_spec(documentdb_core.bson): The BSON specification for the user update.
Returns
- A BSON document representing the updated user.
users_info()
Description
This function retrieves information about users.
Syntax
documentdb_api.users_info(p_spec documentdb_core.bson)
Parameters
-
p_spec(documentdb_core.bson): The BSON specification for the user information retrieval.
Returns
- A BSON document representing the users' information.
Utility Functions
binary_extended_version()
Description
This function retrieves the extended version of the binary.
Syntax
documentdb_api.binary_extended_version()
Returns
- A text representing the extended version of the binary.
binary_version()
Description
This function retrieves the version of the binary.
Syntax
documentdb_api.binary_version()
Returns
- A text representing the version of the binary.