本文整理汇总了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});
});
});
示例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;
}
示例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);
});
});
示例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');
}
});
});
示例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
})
}
});
示例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;
}
示例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;
}
示例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]
}
});
});
示例9:
jobs.forEach((job: any) => {
const temp = JSON.parse(JSON.stringify(job));
logs[temp['_id']] = [];
ids.push(ObjectId(temp['_id']));
});