Methods
(static) countUnreadStatuses(owner, inboxType, options) → {Promise}
Count unread statuses in someone's inbox.
Example
AV.Status.countUnreadStatuses(AV.User.current()).then(function(response){
console.log(response.unread); //unread statuses number.
console.log(response.total); //total statuses number.
});
Parameters:
Name | Type | Description |
---|---|---|
owner |
AV.User | The status owner. |
inboxType |
String | The inbox type, 'default' by default. |
options |
AuthOptions |
Returns:
A promise that is fulfilled when the count
completes.
- Type
- Promise
(static) inboxQuery(owner, inboxType) → {AV.InboxQuery}
- Source:
- Since:
- 0.3.0
- See:
Create a inbox status query to find someone's inbox statuses.
Example
//Find current user's default inbox statuses.
var query = AV.Status.inboxQuery(AV.User.current());
//find the statuses after the last message id
query.sinceId(lastMessageId);
query.find().then(function(statuses){
//process statuses
});
Parameters:
Name | Type | Description |
---|---|---|
owner |
AV.User | The inbox's owner |
inboxType |
String | The inbox type,'default' by default. |
Returns:
The inbox query object.
- Type
- AV.InboxQuery
(static) resetUnreadCount(owner, inboxType, options) → {Promise}
reset unread statuses count in someone's inbox.
Example
AV.Status.resetUnreadCount(AV.User.current()).then(function(response){
console.log(response.unread); //unread statuses number.
console.log(response.total); //total statuses number.
});
Parameters:
Name | Type | Description |
---|---|---|
owner |
AV.User | The status owner. |
inboxType |
String | The inbox type, 'default' by default. |
options |
AuthOptions |
Returns:
A promise that is fulfilled when the reset
completes.
- Type
- Promise
(static) sendPrivateStatus(status, target, options) → {Promise}
Send a status from current signined user to other user's private status inbox.
Example
// send a private status to user '52e84e47e4b0f8de283b079b'
var status = new AVStatus('image url', 'a message');
AV.Status.sendPrivateStatus(status, '52e84e47e4b0f8de283b079b').then(function(){
//send status successfully.
}, function(err){
//an error threw.
console.dir(err);
});
Parameters:
Name | Type | Description |
---|---|---|
status |
AV.Status | A status object to be send to followers. |
target |
String | The target user or user's objectId. |
options |
AuthOptions |
Returns:
A promise that is fulfilled when the send
completes.
- Type
- Promise
(static) sendStatusToFollowers(status, options) → {Promise}
Send a status to current signined user's followers.
Example
var status = new AVStatus('image url', 'a message');
AV.Status.sendStatusToFollowers(status).then(function(){
//send status successfully.
}, function(err){
//an error threw.
console.dir(err);
});
Parameters:
Name | Type | Description |
---|---|---|
status |
AV.Status | A status object to be send to followers. |
options |
AuthOptions |
Returns:
A promise that is fulfilled when the send
completes.
- Type
- Promise
(static) statusQuery(source) → {AV.Query}
Create a status query to find someone's published statuses.
Example
//Find current user's published statuses.
var query = AV.Status.statusQuery(AV.User.current());
query.find().then(function(statuses){
//process statuses
});
Parameters:
Name | Type | Description |
---|---|---|
source |
AV.User | The status source, typically the publisher. |
Returns:
The query object for status.
- Type
- AV.Query
destroy(options) → {Promise}
Destroy this status,then it will not be avaiable in other user's inboxes.
Parameters:
Name | Type | Description |
---|---|---|
options |
AuthOptions |
Returns:
A promise that is fulfilled when the destroy
completes.
- Type
- Promise
get(attr)
Gets the value of an attribute in status data.
Parameters:
Name | Type | Description |
---|---|---|
attr |
String | The string name of an attribute. |
send(options) → {Promise}
Send a status by a AV.Query object.
Example
// send a status to male users
var status = new AVStatus('image url', 'a message');
status.query = new AV.Query('_User');
status.query.equalTo('gender', 'male');
status.send().then(function(){
//send status successfully.
}, function(err){
//an error threw.
console.dir(err);
});
Parameters:
Name | Type | Description |
---|---|---|
options |
AuthOptions |
Returns:
A promise that is fulfilled when the send
completes.
- Type
- Promise
set(key, value)
Sets a hash of model attributes on the status data.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The key to set. |
value |
any | The value to give it. |
toObject() → {AV.Object}
Cast the AV.Status object to an AV.Object pointer.
Returns:
A AV.Object pointer.
- Type
- AV.Object