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


TypeScript ObjectID.toHexString方法代碼示例

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


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

示例1: Error

				collection.replaceOne({ _id: id }, entity, (err: WriteError, result: UpdateWriteOpResult) => {
					if (err) {
						throw new Error(err.errmsg);
					}

					console.log(result.toString());
					entity._id = id.toHexString();
					subject.next(entity);
					subject.complete();
				});
開發者ID:nickmorton,項目名稱:yes-admin,代碼行數:10,代碼來源:repository-base.ts

示例2: function

                me.db.collection(collection).findOneAndUpdate(query, {$set: userx}, {projection: {_id: 1}}, function (err, r) {
                    if (err) throw err;

                    // case 3 : user doesn't exist
                    if (r.value === null) return updateUserInfo(me.db, themtid, userx, callback);

                    // user exist
                    var ide_mtid:mongodb.ObjectID = r.value._id;
                    // check for case 1
                    if (themtid.toHexString() === ide_mtid.toHexString()) return updateUserInfo(me.db, themtid, userx, callback);

                    // case 2
                    // add to mapping collection
                    me.db.collection(collectionmapping).insertOne({
                        anomtid: themtid,
                        idemtid: ide_mtid,
                        ctime: new Date()
                    }, function (err) {
                        if (err) throw err;
                    });

                    //convert all ano-mtid to ide-mtid
                    var query = {};
                    var update = {};
                    query[ids._mtid] = themtid;
                    update[ids._mtid] = ide_mtid;
                    me.db.collection(collection).updateMany(query, {$set: update}, function (err) {
                        if (err) throw err;
                    });
                    // merge and delete ano-mtid record IF EXISTED
                    me.db.collection(collection).find({_id: themtid}).limit(1).toArray(function (err, r) {
                        if (err) throw err;
                        if (r.length === 0) return;
                        var olduser = r[0];
                        me.mergeInfo(olduser, userx, ids);
                        me.db.collection(collection).deleteOne({_id: themtid}, function (err) {
                            if (err) throw err;
                        });
                        return updateUserInfo(me.db, ide_mtid, userx, callback);
                    });
                });
開發者ID:meotrics,項目名稱:meotrics,代碼行數:41,代碼來源:actionmgr.ts

示例3: 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


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