當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ObjectID.createFromHexString方法代碼示例

本文整理匯總了TypeScript中mongodb.ObjectID.createFromHexString方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ObjectID.createFromHexString方法的具體用法?TypeScript ObjectID.createFromHexString怎麽用?TypeScript ObjectID.createFromHexString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mongodb.ObjectID的用法示例。


在下文中一共展示了ObjectID.createFromHexString方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: findOneById

  public findOneById(userId: string, markId: string): Promise<Mark> {
    assert(userId);
    assert(markId);

    const query = {
      "_id": ObjectID.createFromHexString(markId),
      "user._id": ObjectID.createFromHexString(userId)
    };

    return this.findOne(query);
  }
開發者ID:douglascvas,項目名稱:biblicando-backend,代碼行數:11,代碼來源:MarkDao.ts

示例2: it

 it('equal players with entity ids are equal', function () {
     const batman = {
         name: 'Batman',
         _id: ObjectID.createFromHexString('000000079bb31fb01ee7834c'),
         tribe: 'what'
     };
     const anotherBatman = {
         name: 'Batman',
         _id: ObjectID.createFromHexString('000000079bb31fb01ee7834c'),
         tribe: 'what'
     };
     expect(Comparators.areEqualPlayers(batman, anotherBatman)).toBe(true);
 })
開發者ID:robertfmurdock,項目名稱:Coupling,代碼行數:13,代碼來源:Comparators-spec.ts

示例3: findByVerse

  public findByVerse(userId: string, verseId: ObjectID, options: any): Promise<Mark[]> {
    assert(userId);
    assert(verseId);

    const query = {
      "user._id": ObjectID.createFromHexString(userId),
      "verse._id": verseId
    };

    return this.find(query, options);
  }
開發者ID:douglascvas,項目名稱:biblicando-backend,代碼行數:11,代碼來源:MarkDao.ts

示例4: findByTag

  public findByTag(userId: string, tags: string[]): Promise<Mark[]> {
    assert(userId);
    assert(tags);

    const query = {
      "user._id": ObjectID.createFromHexString(userId),
      "tag": {
        $in: tags
      }
    };

    return this.find(query);
  }
開發者ID:douglascvas,項目名稱:biblicando-backend,代碼行數:13,代碼來源:MarkDao.ts

示例5: upsertOne

 public upsertOne(chapter: Chapter): Promise<Chapter> {
   const self = this;
   let queries = [];
   if (chapter._id) {
     queries.push({_id: ObjectID.createFromHexString(chapter._id)});
   }
   if (chapter.remoteId) {
     queries.push({remoteId: chapter.remoteId});
   }
   let query: any = (queries.length > 1 ? {$or: queries} : queries[0]);
   if (query) {
     return self.updateOne(query, chapter, {upsert: true});
   } else {
     return self.insertOne(chapter);
   }
 }
開發者ID:douglascvas,項目名稱:biblicando-backend,代碼行數:16,代碼來源:ChapterDao.ts

示例6: removeFromVerses

  /**
   * Exclude all marks whose `insertDate` is not equal `insertDateToIgnore`.
   */
  public removeFromVerses(userId: string, verseIds: string[], insertDateToIgnore: Date) {
    insertDateToIgnore = insertDateToIgnore || null;
    assert(userId);
    assert(verseIds);

    const query: any = {
      "verse._id": {
        $in: verseIds
      },
      "user._id": ObjectID.createFromHexString(userId)
    };
    if (insertDateToIgnore) {
      query.insertDate = {
        $ne: insertDateToIgnore
      }
    }

    return this.remove(query);
  }
開發者ID:douglascvas,項目名稱:biblicando-backend,代碼行數:22,代碼來源:MarkDao.ts

示例7: it

    it("should correctly diff ObjectIDs", function () {
        let oldID = new MongoDB.ObjectID();
        let newID = MongoDB.ObjectID.createFromHexString(oldID.toHexString());

        let oldObject = { _id: oldID };
        let newObject = { _id: newID };
        let expectedDiff = {

        };

        chai.expect(Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff);

        newID = new MongoDB.ObjectID();

        oldObject = { _id: oldID };
        newObject = { _id: newID };
        expectedDiff = {
            $set: { _id: newID }
        };

        chai.expect(Omnom.diff(oldObject, newObject)).to.exist.and.be.eql(expectedDiff);
    });
開發者ID:apapacy,項目名稱:Iridium,代碼行數:22,代碼來源:Omnom.ts

示例8: toObjectID

export function toObjectID(value: string): MongoDB.ObjectID {
	return MongoDB.ObjectID.createFromHexString(value);
}
開發者ID:SierraSoftworks,項目名稱:Iridium,代碼行數:3,代碼來源:ObjectID.ts


注:本文中的mongodb.ObjectID.createFromHexString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。