本文整理汇总了TypeScript中collections/books.Books类的典型用法代码示例。如果您正苦于以下问题:TypeScript Books类的具体用法?TypeScript Books怎么用?TypeScript Books使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Books类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Promise
let promise = new Promise((resolve, reject) => {
let book = LocalBooks.findOne({_id: bookid})
if(!book) return;
if(book.cloud == false){
book.cloud = true;
book.owner = Meteor.userId();
Books.insert(book, (err, id) => {
if(err){
reject(err)
}else{
LocalBooks.update({_id:bookid}, {
$set: {
cloud: true,
owner: Meteor.userId()
}
})
resolve(true)
}
})
}else{
Books.update(book, (err, res) => {
if(err){
reject(err)
}else{
resolve(true)
}
})
}
})
示例2: resolve
Meteor.subscribe('books', (err) => {
if(err){
resolve(false)
return
}
let books = Books.find().fetch()
for(let bk of books){
if(!bk.readed){
bk['readed'] = bk.modified
}
bk['cloud'] = true
let localbk = LocalBooks.findOne({_id: bk._id})
if(!localbk){
LocalBooks.insert(bk)
}else{
if(bk.modified > localbk.modified){
this.UpdateBook(bk)
}
}
}
resolve(true)
});
示例3: function
Meteor.publish('books', function() {
try{
return Books.find({owner: this.userId, deleted: false});
}catch(err){
LogDB(err.toString(), 'publish books', this.userId)
return null
}
});