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


TypeScript mongodb.ObjectID函數代碼示例

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


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

示例1: function

		router.get('/edit',function(req, res) {
			var db = req.db;
			var registeredUsers = db.get('registeredUsers');
			registeredUsers.findOne({_id:ObjectID(req.cookies._id)}, function(err, user) {
					res.render('editprofile', {"user":user});
			});
		});
開發者ID:TylerWardle,項目名稱:MATA_Clone,代碼行數:7,代碼來源:profile.ts

示例2: getContributor

	getContributor(req: any, res: any): Boolean {
	    var db = req.db;
        var contributors = db.get('contributors');
        var registeredUsers = db.get('registeredUsers');
        var comicsDB = db.get('comics');
        var c = new Comic.Comic(req.mongoose);
        var cc = new ComicCell.ComicCell(req.mongoose);
        var s = new Service.SearchBrowseService(req.mongoose);
        var history = new HistoryServiceProvider.HistoryServiceProvider();
            
      	registeredUsers.findOne({_id: ObjectID(req.cookies._id)}, function(error, contributor)
    	{
            s.getComics(req,(comics:any): void =>{
                registeredUsers.find({username: {$in: contributor.subscriptions}}, function(err, users) {
                    comicsDB.find({_id: {$in: contributor.webComicViewingHistory}} , {sort: {_id:-1}}, function(err, comicsViewed) {
         		        res.render('contributor',{  "users": users, 
                                                    "contributor": contributor,
                                                    "header": req.headers['host'] + "/webcomic/",
                                                    "comics": comics,
                                                    "viewedComics": comicsViewed
                                                    });
                    });
                });    	
            });	
        });

		return true;
	}
開發者ID:TylerWardle,項目名稱:MATA_Clone,代碼行數:28,代碼來源:ContributorServiceProvider.ts

示例3: ObjectID

            this.connect(function (err: any, db: any) {
                assert.equal(null, err);



                db.collection(name).findOne({ "_id": ObjectID(id) }, function (err: any, doc: any) {
                    if (err !== null || doc === null)
                        callback({ "error": "not found" });
                    else
                        callback(doc);
                });


            });
開發者ID:gitter-badger,項目名稱:nodulus,代碼行數:14,代碼來源:mongodb.ts

示例4: function

		router.get('/', function(req, res, db) {
			//console.log("Reached");
			var db = req.db;
			var registeredUsers = db.get('registeredUsers');
			
			registeredUsers.findOne({_id: ObjectID(req.cookies._id)}, function(error, user)
			{
				if(user.accountType == 'viewer'){
					 res.redirect('viewer');

				}else{
					res.redirect('contributor');  
				}
			});
		});
開發者ID:TylerWardle,項目名稱:MATA_Clone,代碼行數:15,代碼來源:home.ts

示例5: function

						viewers.findOne({guid:ObjectID(req.cookies._id)}, function(err, viewer) {
							if (err) {
								res.send("ACCESS DENIED" + err);
							}
							else
							{
								// need to ask client to give format of data being sent up for account settings..
								// are they only sending updated settings? or all.
								viewers.update({guid:ObjectID(req.cookies._id)},{
									username: viewer.username,
									firstName: req.body.firstName,
									lastName: req.body.lastName,
									guid: viewer.guid
								})
							}
						});
開發者ID:TylerWardle,項目名稱:MATA_Clone,代碼行數:16,代碼來源:AccountSettingsServiceProvider.ts

示例6: getAccountSettings

	getAccountSettings(req: any, res: any): Boolean
	{
		var db = req.db;
		var registeredUsers = db.get('registeredUsers');
			
			 // Fetch the document
			registeredUsers.findOne({_id:ObjectID(req.cookies._id)}, function(err, user) {
				if(user)
				{			
				   res.render('accountsettings', { "accountsettings": user });
				}else
				{
					res.send("ACCESS DENIED");
				}
			});
		
		return true;
	}
開發者ID:TylerWardle,項目名稱:MATA_Clone,代碼行數:18,代碼來源:AccountSettingsServiceProvider.ts

示例7: getViewer

	getViewer(req: any, res: any): Boolean {
		var db = req.db;
		var viewers = db.get('viewers');
        var c = new Comic.Comic(req.mongoose);
		var cc = new ComicCell.ComicCell(req.mongoose);
		var s = new Service.SearchBrowseService(req.mongoose);
		//var comicsList = "https://fast-beach-12058.herokuapp.com/webcomic/id/56bac1a83da2ef110089f60e, https://fast-beach-12058.herokuapp.com/webcomic/id/56bac1a83da2ef110089f60f";
				
		viewers.findOne({guid: ObjectID(req.cookies._id)}, function(error, viewer)
		{
			s.getComicsForViewer(req,(comics:any): void =>{
		        res.render('viewer',{"viewer": viewer,"header": req.headers['host'] + "/webcomic/", "comics": comics});    
            }); 

		});

		return true;
	}
開發者ID:TylerWardle,項目名稱:MATA_Clone,代碼行數:18,代碼來源:ViewerServiceProvider.ts

示例8: function

 cc.insert(comicID, authorID, authorID, toPublish, (imgName: String): void=> {
     // If there's an error
     if (!imgName) {
         console.log("There was an error")
         res.redirect("./create");
         res.end();
     } else {
         //var newPath = "./uploads/fullsize/" + imgName;
         c.update(comicID, title, authorID, authorUsername, publicationDate, description, genre, toPublish, openToContribution, openToCommenting, imgName, upvotes,votedPpl,fave, (): void => {});
         var newPath = "./uploads/fullsize/" + imgName;
         //var imageList = [(req.headers['host'] + "/webcomic/image/" + imgName)];
 
         // write image file to uploads/fullsize folder
         fs.writeFile(newPath, img, function (err) {
             if (err)
                 return console.error(err);
             //redirect to the newly created comic
             res.redirect('./id/' + comicID);
         });
         easyimg.rescrop({
             src: newPath, dst:'./uploads/thumbnails/' + imgName,
             width:128, height:128,
             //cropwidth:128, cropheight:128,
             x:0, y:0
             }).then(
             function(image) {
                 console.log('Resized and cropped: ' + image.width + ' x ' + image.height);
             },
             function (err) {
                 console.log(err);
             }
             );
     }
     
     var db = req.db;
     var contributors = db.get('contributors');
     contributors.update({ guid: ObjectId(req.cookies._id) }, {
         $addToSet: {
             comicIDs: [comicID]
         }
     });
     
 });
開發者ID:TylerWardle,項目名稱:MATA_Clone,代碼行數:43,代碼來源:webcomic.ts

示例9:

 jobs.forEach((job: any) => {
     const temp = JSON.parse(JSON.stringify(job));
     logs[temp['_id']] = [];
     ids.push(ObjectId(temp['_id']));
 });
開發者ID:damisv,項目名稱:steemBotJobs,代碼行數:5,代碼來源:logs.router.ts


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