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


TypeScript ObjectID.toString方法代码示例

本文整理汇总了TypeScript中mongodb.ObjectID.toString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ObjectID.toString方法的具体用法?TypeScript ObjectID.toString怎么用?TypeScript ObjectID.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mongodb.ObjectID的用法示例。


在下文中一共展示了ObjectID.toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Set

      const addIdsToQueryMap = (access: boolean) => (id: string | ObjectID) => {
        const accessString = access ? 'positive' : 'negative';
        const altAccessString = access ? 'negative' : 'positive';
        const resourceUid = Tyr.byName[linkedCollectionName].idToUid(id);

        if (alreadySet.has(resourceUid)) {
          return;
        } else {
          alreadySet.add(resourceUid);
        }

        const accessSet =
          queryMaps[accessString].get(linkedCollectionName) || new Set();
        if (!queryMaps[accessString].has(linkedCollectionName)) {
          queryMaps[accessString].set(linkedCollectionName, accessSet);
        }

        // if the id was set previously, by a lower level link,
        // dont override the lower level
        const map = queryMaps[altAccessString].get(linkedCollectionName);

        if (!map || !map.has(id.toString())) {
          accessSet.add(id as string);
        }
      };
开发者ID:tyranid-org,项目名称:tyranid,代码行数:25,代码来源:query.ts

示例2: async

	connection.on('message', async (data) => {
		const msg = JSON.parse(data.utf8Data);

		switch (msg.type) {
			case 'read':
					if (!msg.id) {
						return;
					}

					const id = new mongodb.ObjectID(msg.id);

					// Fetch message
					// SELECT _id, user_id, is_read
					const message = await Message.findOne({
						_id: id,
						recipient_id: user._id
					}, {
						fields: {
							_id: true,
							user_id: true,
							is_read: true
						}
					});

					if (message == null) {
						return;
					}

					if (message.is_read) {
						return;
					}

					// Update documents
					await Message.update({
						_id: id
					}, {
						$set: { is_read: true }
					});

					// Publish event
					publishMessagingStream(message.user_id, user._id, 'read', id.toString());
				break;
		}
	});
开发者ID:syuilo,项目名称:misskey-core,代码行数:44,代码来源:messaging.ts

示例3: getExplainationsForId

/**
 * given a node in the debug graph,
 * find the path of nodes leading to a permission
 */
function getExplainationsForId(
  id: ObjectID,
  subjectId: string,
  subjectGraph: Map<string, string[]>,
  graph: DebugGraph,
  type: ExplainationType,
  property: string
): Explaination[] {
  const node = graph.get(id.toString());

  if (!node) {
    throw new Error(`No node found for id = ${id}`);
  }

  const nodeUid = toUid(node.collectionName, id);

  const out: Explaination[] = [];

  /**
   * the node itself represents a direct permission
   */
  if (!('parents' in node)) {
    const subjectPaths = getSubjectPaths(
      subjectId,
      node.subjectId,
      subjectGraph
    );
    const resourcePath = [nodeUid];

    for (const path of subjectPaths) {
      out.push({
        permissionId: node.permission.toString(),
        subjectPath: path,
        permissionType: node.type,
        property,
        resourcePath,
        type: ExplainationType.ALLOW
      });
    }

    return out;
  }

  /**
   * recurse up parent chain, building explaination objects with uid path
   */

  let currentNodes = [
    {
      type,
      resourcePath: [nodeUid],
      parents: Array.from(node.parents)
    }
  ];

  while (currentNodes.length) {
    const nextNodes: (Explaination & { parents: string[] })[] = [];

    for (const current of currentNodes) {
      const { parents, resourcePath } = current;

      for (const parent of parents) {
        const next = graph.get(parent);

        if (!next) {
          throw new Error(`No node found for parentId = ${parent}`);
        }

        const parentUid = toUid(next.collectionName, parent);
        const nextPath = [...resourcePath, parentUid];

        if (!('parents' in next)) {
          const subjectPaths = getSubjectPaths(
            subjectId,
            next.subjectId,
            subjectGraph
          );

          for (const subjectPath of subjectPaths) {
            out.push({
              type,
              resourcePath: nextPath,
              subjectPath,
              permissionId: next.permission.toString(),
              permissionType: next.type,
              property
            });
          }
        } else {
          nextNodes.push({
            type,
            resourcePath: nextPath,
            subjectPath: [],
            parents: Array.from(next.parents)
          });
        }
//.........这里部分代码省略.........
开发者ID:tyranid-org,项目名称:tyranid,代码行数:101,代码来源:explain.ts

示例4: id

 get id(): string {
   return this._id.toString();
 }
开发者ID:sebthieti,项目名称:jogplayer-online,代码行数:3,代码来源:user.model.ts


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