本文整理汇总了TypeScript中collections/books.LocalBooks类的典型用法代码示例。如果您正苦于以下问题:TypeScript LocalBooks类的具体用法?TypeScript LocalBooks怎么用?TypeScript LocalBooks使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LocalBooks类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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)
});
示例2: 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)
}
})
}
})
示例3: reject
Books.insert(book, (err, id) => {
if(err){
reject(err)
}else{
LocalBooks.update({_id:bookid}, {
$set: {
cloud: true,
owner: Meteor.userId()
}
})
resolve(true)
}
})
示例4: reject
Books.insert(book, (err, id) => {
if(err){
reject(err)
}else{
LocalBooks.update({_id:bookid}, {
$set: {
cloud: true,
owner: Session.get('userid')
}
})
resolve(true)
}
})
示例5: addDefaultBook
private addDefaultBook(){
LocalBooks.insert({
name: '本地书集',
description: '',
icon: null,
author: '我本人',
owner: null,
readpermission: 0,
writepermission: 0,
created: Date.now(),
modified: Date.now(),
readed: Date.now(),
cloud: false,
public: false,
deleted: false
})
}
示例6: UpdateBook
private UpdateBook(bk: Book){
LocalBooks.update({_id: bk._id}, {
$set: {
name: bk.name,
description: bk.description,
icon: bk.icon,
author: bk.author,
owner: bk.owner,
readpermission: bk.readpermission,
writepermission: bk.writepermission,
created: bk.created,
modified: bk.modified,
readed: bk.readed,
cloud: bk.cloud,
deleted: bk.deleted,
public: bk.public
}
})
}
示例7: MyBooks
get MyBooks(){
return LocalBooks.find({}, {sort: {readed: 'desc'}}).fetch();
}