当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript books.LocalBooks类代码示例

本文整理汇总了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)
 });
开发者ID:maiernte,项目名称:Project,代码行数:25,代码来源:bookmanager.ts

示例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)
                    }
                })
            }
        })
开发者ID:maiernte,项目名称:Project,代码行数:32,代码来源:bookmanager.ts

示例3: reject

                Books.insert(book, (err, id) => {
                    if(err){
                        reject(err)
                    }else{
                        LocalBooks.update({_id:bookid}, {
                            $set: {
                                cloud: true,
                                owner: Meteor.userId()
                            }
                        })

                        resolve(true)
                    }
                })
开发者ID:maiernte,项目名称:Project,代码行数:14,代码来源:bookmanager.ts

示例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)
                    }
                })
开发者ID:maiernte,项目名称:projectmix,代码行数:14,代码来源:bookmanager.ts

示例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
     })
 }
开发者ID:maiernte,项目名称:Project,代码行数:17,代码来源:bookmanager.ts

示例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
         }
     })
 }
开发者ID:maiernte,项目名称:Project,代码行数:19,代码来源:bookmanager.ts

示例7: MyBooks

 get MyBooks(){
     return LocalBooks.find({}, {sort: {readed: 'desc'}}).fetch();
 }
开发者ID:maiernte,项目名称:Project,代码行数:3,代码来源:bookmanager.ts


注:本文中的collections/books.LocalBooks类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。