Insert a 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 a document.
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 documents.
returns Array<Object>
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"
}
]
*/
Check if they have document.
returns Boolean
Example:
accounts.has(document => document.region === "Muğla"); // -> true
accounts.has({"region": "Muğla"}); // -> true
update(document_id, document)
Update a 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 a document.
returns Boolean
Example:
let document = accounts.find(document => document.email === "fir4tozden@gmail.com");
accounts.archive(document._id); // -> true
Unarchive a document.
returns Boolean
Example:
let document = accounts.find(document => document.email === "fir4tozden@gmail.com", {"archived": true});
accounts.unarchive(document._id); // -> true
Delete a document.
returns Boolean
Example:
let document = accounts.find(document => document.email === "fir4tozden@gmail.com");
accounts.delete(document._id); // -> true