DocumentBasedCollection
Methods for document-based collections.
insert(document)
insert(document)
Insert a document.
document
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(params, options)
Find a document.
params
options
options.archived
returns Object
Example:
accounts.find(document => document.email === "fir4tozden@gmail.com", {"archived": true}); // or accounts.find({"email": "fir4tozden@gmail.com"}, {"archived": true}); /* { "_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" } */
filter(params, options)
filter(params, options)
Filter documents.
params
options
options.archived
Example:
accounts.filter(document => document.region === "Muğla", {"archived": true}); // or accounts.filter({"region": "Muğla"}, {"archived": true}); /* [ { "_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" }, { "_id": "23ERK9fHqiH_n83fhzU7eOYtzz6tUl7S", "_updated": false, "_archived": false, "_created_at": 2022-03-20T00:05:00.000Z, "_created_timestamp": 1647734700000, "email": "nehir@gmail.com", "username": "nehir", "password": "12345678", "region": "Muğla" } ] */
has(params, options)
has(params, options)
Check if they have document.
params
options
options.archived
returns Boolean
Example:
accounts.has(document => document.region === "Muğla"); // -> true accounts.has({"region": "Muğla"}); // -> true
update(document_id, document)
update(document_id, document)
Update a document.
document_id
document
returns Object
Example:
let document = accounts.find(document => document.email === "fir4tozden@gmail.com"); accounts.update(document._id, {"email": "fir4tozden@gmail.com", "username": "hey_im_fir4tozden", "password": "87654321", "region": "İstanbul"}); /* { "_id: "23ERK9fHqiH_n83fhzU7eOYtzz6tUl7S", "_updated": true, "_archived": false, "_created_at": 2022-03-20T00:00:00.000Z, "_created_timestamp": 1647745200000, "_updated_at": 2022-03-20T00:10:00.000Z, "_updated_timestamp": 1647735000000, "email": "fir4tozden@gmail.com", "username": "hey_im_fir4tozden", "password": "87654321", "region": "İstanbul" } */
archive(document_id)
archive(document_id)
Archive a document.
document_id
returns Boolean
Example:
let document = accounts.find(document => document.email === "fir4tozden@gmail.com"); accounts.archive(document._id); // -> true
unarchive(document_id)
unarchive(document_id)
Unarchive a document.
document_id
returns Boolean
Example:
let document = accounts.find(document => document.email === "fir4tozden@gmail.com", {"archived": true}); accounts.unarchive(document._id); // -> true
delete(document_id)
delete(document_id)
Delete a document.
document_id
returns Boolean
Example:
let document = accounts.find(document => document.email === "fir4tozden@gmail.com"); accounts.delete(document._id); // -> true
Last updated