当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript MongoProvider.buildId方法代码示例

本文整理汇总了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);
	}
开发者ID:Frost-Dev,项目名称:Frost,代码行数:15,代码来源:UserRelationService.ts

示例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;
	}
开发者ID:Frost-Dev,项目名称:Frost,代码行数:15,代码来源:TokenService.ts

示例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;
	}
开发者ID:Frost-Dev,项目名称:Frost,代码行数:25,代码来源:UserRelationService.ts

示例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));
	}
开发者ID:Frost-Dev,项目名称:Frost,代码行数:7,代码来源:AppService.ts

示例5: async

}, async (manager) => {

	// params
	const userId: string = manager.params.userId;

	const chatPostings = await timeline(manager, [MongoProvider.buildId(userId)]);

	manager.ok(new PostingsResponseObject(chatPostings));
});
开发者ID:Frost-Dev,项目名称:Frost,代码行数:9,代码来源:list.ts

示例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;
	}
开发者ID:Frost-Dev,项目名称:Frost,代码行数:19,代码来源:UserRelationService.ts

示例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);
	}
开发者ID:Frost-Dev,项目名称:Frost,代码行数:15,代码来源:PostingService.ts

示例8:

			source.attachmentIds = attachmentIds.map(i => MongoProvider.buildId(i));
开发者ID:Frost-Dev,项目名称:Frost,代码行数:1,代码来源:PostingService.ts


注:本文中的frost-component.MongoProvider.buildId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。