本文整理汇总了TypeScript中frost-component.MongoProvider.buildId方法的典型用法代码示例。如果您正苦于以下问题:TypeScript MongoProvider.buildId方法的具体用法?TypeScript MongoProvider.buildId怎么用?TypeScript MongoProvider.buildId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frost-component.MongoProvider
的用法示例。
在下文中一共展示了MongoProvider.buildId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: unfollow
async unfollow(sourceUserId: string | ObjectId, targetUserId: string | ObjectId) {
const query = {
sourceUserId: MongoProvider.buildId(sourceUserId),
targetUserId: MongoProvider.buildId(targetUserId)
};
const docSource: IUserRelationDocumentSoruce = {
sourceUserId: query.sourceUserId,
targetUserId: query.targetUserId,
message: undefined,
status: 'notFollowing'
};
const docRaw: IUserRelationDocument = await this.db.upsert('api.userRelations', query, docSource);
return new UserRelationDocument(docRaw);
}
示例2: find
async find(appId: string | ObjectId, userId: string | ObjectId, scopes: string[]): Promise<TokenDocument | null> {
const scopesQuery: any = { $size: scopes.length };
// NOTE: 空の配列を$allに指定すると検索にヒットしなくなるので、空のときは$allを指定しない
if (scopes.length != 0) {
scopesQuery.$all = scopes;
}
const tokenDocRaw = await this.db.find('api.tokens', {
appId: MongoProvider.buildId(appId),
userId: MongoProvider.buildId(userId),
scopes: scopesQuery
});
return tokenDocRaw ? new TokenDocument(tokenDocRaw) : null;
}
示例3: getfollowers
async getfollowers(userId: string | ObjectId): Promise<UserDocument[]> {
const docRaws: IUserRelationDocument[] = await this.db.findArray('api.userRelations', {
targetUserId: MongoProvider.buildId(userId),
status: 'following'
});
const followers = docRaws.map(docRaw => new UserRelationDocument(docRaw));
const userPromises = followers.map(async follower => {
const user = await this.manager.userService.findById(follower.sourceUserId);
if (!user) {
console.warn(`not existing user: ${follower.sourceUserId.toHexString()}`);
}
return user;
});
const usersWithNull = await Promise.all(userPromises);
const users: UserDocument[] = [];
for (const userOrNull of usersWithNull) {
if (userOrNull) users.push(userOrNull);
}
return users;
}
示例4: findArrayByCreatorId
async findArrayByCreatorId(creatorId: string | ObjectId): Promise<AppDocument[]> {
const rawAppDocs: IAppDocument[] = await this.db.findArray('api.apps', {
creatorId: MongoProvider.buildId(creatorId)
});
return rawAppDocs.map(rawAppDoc => new AppDocument(rawAppDoc));
}
示例5: async
}, async (manager) => {
// params
const userId: string = manager.params.userId;
const chatPostings = await timeline(manager, [MongoProvider.buildId(userId)]);
manager.ok(new PostingsResponseObject(chatPostings));
});
示例6: getRelation
async getRelation(sourceUserId: string | ObjectId, targetUserId: string | ObjectId): Promise<IUserRelation> {
const docRaw: IUserRelationDocument = await this.db.find('api.userRelations', {
sourceUserId: sourceUserId,
targetUserId: targetUserId
});
if (!docRaw) {
return {
sourceUserId: MongoProvider.buildId(sourceUserId).toHexString(),
targetUserId: MongoProvider.buildId(targetUserId).toHexString(),
status: 'notFollowing'
};
}
const userRelationDoc = new UserRelationDocument(docRaw);
const userRelation = await userRelationDoc.pack(this.db);
return userRelation;
}
示例7: createChatPosting
async createChatPosting(userId: string | ObjectId, text: string, attachmentIds?: (ObjectId | string)[]): Promise<ChatPostingDocument> {
const source: IChatPostingDocumentSoruce = {
type: 'chat',
userId: MongoProvider.buildId(userId),
text
};
if (attachmentIds) {
source.attachmentIds = attachmentIds.map(i => MongoProvider.buildId(i));
}
const documentRaw: IChatPostingDocument = await this.db.create('api.postings', source);
return new ChatPostingDocument(documentRaw);
}
示例8:
source.attachmentIds = attachmentIds.map(i => MongoProvider.buildId(i));