本文整理汇总了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();
}