本文整理匯總了TypeScript中schemas/conversationSchema.js.default類的典型用法代碼示例。如果您正苦於以下問題:TypeScript js.default類的具體用法?TypeScript js.default怎麽用?TypeScript js.default使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了js.default類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: previewList
async previewList() {
//Get Conversations and sort by date
var conversations = await ConversationDB.find({}).sort({date: 'desc'});
//Get First Message of each Conversation and append to each conversation
var mostRecentMessageIds = []
conversations.forEach((conversation) => {
var messageId = conversation.Messages[conversation.Messages.length - 1]
mostRecentMessageIds.push(messageId);
})
var firstMessages = await messageModel.getMessagesByIds(mostRecentMessageIds);
var newConversations = []
firstMessages.forEach((message, i) => {
var newConvo = {
firstMessage: '',
convo: ''
}
newConvo.firstMessage = firstMessages[i].Body;
newConvo.convo = conversations[i];
newConversations.push(newConvo);
})
var data = {
data: newConversations
}
return data;
}
示例2: createConversation
async createConversation(roomId: string, AFingerprint: string, BFingerprint: string) {
return await ConversationDB.findOneAndUpdate(
{
'RoomId': roomId
},{
safe: true,
new: true,
upsert: true
});
}
示例3: updateConversation
async updateConversation(roomId: string, message: string) {
return await ConversationDB
.findOneAndUpdate({
'RoomId': roomId
}, {
'Date': Date.now(),
'$push': { 'Messages': message }
}, {
safe: true, upsert: true, new: true
});
}
示例4: all
async all() {
return await ConversationDB.find();
}