DocumentBasedCollection

Methods for document-based collections.

insert(document)

Insert a document.

Parameter
Description

document

Object The document to be written to the collection.

returns Object

Example:

accounts.insert({"email": "fir4tozden@gmail.com", "username": "fir4tozden", "password": "12345678", "region": "Muğla"});
/*
  {
    "_id": "RMmXZVDfQrVLQwFlquMPb98XNUCxQ6MM",
    "_updated": false,
    "_archived": false,
    "_created_at": 2022-03-20T00:00:00.000Z,
    "_created_timestamp": 1647745200000,
    "email": "fir4tozden@gmail.com",
    "username": "fir4tozden",
    "password": "12345678",
    "region": "Muğla"
  }
*/

find(params, options)

Find a document.

Parameter
Description

params

Function | Object The parameters you will use to find the data.

options

Object (optional) Find options.

options.archived

Boolean (optional) Whether to find archived documents.

returns Object

Example:

filter(params, options)

Filter documents.

Parameter
Description

params

Function | Object The parameters you will use to filter the data.

options

Object (optional) Filter options.

options.archived

Boolean (optional) Whether to filter archived documents.

returns Array<Object>

Example:

has(params, options)

Check if they have document.

Parameter
Description

params

Function | Object The parameters you will use to check the data.

options

Object (optional) Find options.

options.archived

Boolean (optional) Whether to has archived documents.

returns Boolean

Example:

update(document_id, document)

Update a document.

Parameter
Description

document_id

String The ID of the document to be updated.

document

Object The document to be updated in the collection.

returns Object

Example:

archive(document_id)

Archive a document.

Parameter
Description

document_id

String The ID of the document to be archived.

returns Boolean

Example:

unarchive(document_id)

Unarchive a document.

Parameter
Description

document_id

String The ID of the document to be unarchived.

returns Boolean

Example:

delete(document_id)

Delete a document.

Parameter
Description

document_id

String The ID of the document to be deleted.

returns Boolean

Example:

Last updated