class Collection (View source)

Class Collection

Methods

__construct()

Collection constructor

add(mixed $document)

Add collection document

addOrReplaceOne(string $id, mixed $document)

Add or replace collection document

int
count()

Get document count

createIndex(string $index_name, string $index_desc_json)

Create collection index

bool
dropIndex(string $index_name)

Drop collection index

bool
existsInDatabase()

Check if collection exists in database

find(string $search_condition)

No description

string
getName()

Get collection name

mixed
getOne(string $id)

Get one document This is a shortcut for Collection.find("_id = :id").bind("id", id).execute().fetchOne();.

getSchema()

Retrieve the schema object that contains the collection.

getSession()

Get a new Session object from the Collection object.

modify(string $search_condition)

Modify collections that meet specific search conditions. Multiple operations are allowed, and parameter binding is supported.

remove(string $search_condition)

Remove collections that meet specific search conditions. Multiple operations are allowed, and parameter binding is supported.

removeOne(string $id)

Remove one collection document Remove one document from the collection with the corresponding ID. This is a shortcut for Collection.remove("_id = :id").bind("id", id).execute().

replaceOne(string $id, string $doc)

Updates (or replaces) the document identified by ID, if it exists.

Details

__construct()

Collection constructor

CollectionAdd add(mixed $document)

Add collection document

Parameters

mixed $document

Return Value

CollectionAdd

Result addOrReplaceOne(string $id, mixed $document)

Add or replace collection document

Parameters

string $id
mixed $document

Return Value

Result

int count()

Get document count

Return Value

int

The number of documents in the collection.

createIndex(string $index_name, string $index_desc_json)

Create collection index

Parameters

string $index_name
string $index_desc_json

bool dropIndex(string $index_name)

Drop collection index

Parameters

string $index_name

Return Value

bool

bool existsInDatabase()

Check if collection exists in database

Return Value

bool

CollectionFind find(string $search_condition)

No description

Parameters

string $search_condition

Return Value

CollectionFind

string getName()

Get collection name

Return Value

string

mixed getOne(string $id)

Get one document This is a shortcut for Collection.find("_id = :id").bind("id", id).execute().fetchOne();.

Parameters

string $id

Return Value

mixed

Null if object is not found

Schema getSchema()

Retrieve the schema object that contains the collection.

Return Value

Schema

Session getSession()

Get a new Session object from the Collection object.

Return Value

Session

CollectionModify modify(string $search_condition)

Modify collections that meet specific search conditions. Multiple operations are allowed, and parameter binding is supported.

Parameters

string $search_condition

Return Value

CollectionModify

CollectionRemove remove(string $search_condition)

Remove collections that meet specific search conditions. Multiple operations are allowed, and parameter binding is supported.

Parameters

string $search_condition

Return Value

CollectionRemove

Result removeOne(string $id)

Remove one collection document Remove one document from the collection with the corresponding ID. This is a shortcut for Collection.remove("_id = :id").bind("id", id).execute().

Parameters

string $id

Return Value

Result

Result replaceOne(string $id, string $doc)

Updates (or replaces) the document identified by ID, if it exists.

Parameters

string $id
string $doc

Return Value

Result