ስብስቦች

4

የተተረጎመው መጠን

በዚህ ምዕራፍ:

  • ስለሚትዩር መሰረታዊ ገጽታ፤ ቅፅበታዊ ስብስቦች ይማሩ።
  • የሚትዩር ዳታ ሥምሪያ እዴት እንደሚሰራ ይገንዘቡ።
  • ስብስቦችን ከቅንብር ደንቦቻችን ጋር ያዋህዱ።
  • መሰረታዊ ናሙናችንን ወደ የሚሰራ ቅፅበታዊ መተግበሪያ ይለውጡ!
  • ////

    ////

    ////

    ////

    ////

    ////

    ////

    Posts = new Meteor.Collection('posts');
    
    collections/posts.js

    ኣከማች 4-1

    Added a posts collection

    ////

    እን"Var"ው ወይስ ኣን"Var"ው?

    ////

    ////

    ኮንሶል ከኮንሶል ከኮንሶል

    ////

    ተርሚናል

    The Terminal
    The Terminal
    • ////
    • ////
    • ////
    • ////

    የማሰሻ ኮንሶል

    The Browser Console
    The Browser Console
    • ////
    • ////
    • ////
    • ////

    ሞንጎ ሼል

    The Mongo Shell
    The Mongo Shell
    • ////
    • ////
    • ////
    • ////

    ////

    የኣገልጋይ-በኩል ስብስቦች

    ////

    ////

    > db.posts.insert({title: "A new post"});
    
    > db.posts.find();
    { "_id": ObjectId(".."), "title" : "A new post"};
    
    The Mongo Shell

    ሞንጎ በMeteor.com ላይ

    ////

    ////

    ////

    የተገልጋይ-በኩል ስብስቦች

    ////

    ////

    ////

    ስለሚኒሞንጎ መግቢያ

    ////

    የተገልጋይ-ኣገልጋይ ግንኙነት

    ////

    ////

    ////

    > db.posts.find();
    {title: "A new post", _id: ObjectId("..")};
    
    The Mongo Shell
     Posts.findOne();
    {title: "A new post", _id: LocalCollection._ObjectID};
    
    First browser console

    ////

     Posts.find().count();
    1
     Posts.insert({title: "A second post"});
    'xxx'
     Posts.find().count();
    2
    
    First browser console

    ////

    ❯ db.posts.find();
    {title: "A new post", _id: ObjectId("..")};
    {title: "A second post", _id: 'yyy'};
    
    The Mongo Shell

    ////

    ////

     Posts.find().count();
    2
    
    Second browser console

    ////

    ////

    ////

    ቅፅበታዊ ያድርጉት

    ////

    ////

    የውሂብ ቋቱን መሙላት

    ////

    ////

    ////

    $ meteor reset
    

    ////

    ////

    if (Posts.find().count() === 0) {
      Posts.insert({
        title: 'Introducing Telescope',
        author: 'Sacha Greif',
        url: 'http://sachagreif.com/introducing-telescope/'
      });
    
      Posts.insert({
        title: 'Meteor',
        author: 'Tom Coleman',
        url: 'http://meteor.com'
      });
    
      Posts.insert({
        title: 'The Meteor Book',
        author: 'Tom Coleman',
        url: 'http://themeteorbook.com'
      });
    }
    
    server/fixtures.js

    ኣከማች 4-2

    Added data to the posts collection.

    ////

    ////

    ኣጋዦችን ተጠቅሞ ውሂብን ወደ HTML መጻፍ

    ////

     Posts.find().fetch();
    
    Browser console

    ////

    ////

    Template.postsList.helpers({
      posts: function() {
        return Posts.find();
      }
    });
    
    client/views/posts/posts_list.js

    ኣከማች 4-3

    Wired collection into `postsList` template.

    ፈልግ እና ኣምጣ

    ////

    ////

    ////

    Using live data
    Using live data

    ////

    ////

     Posts.insert({
      title: 'Meteor Docs', 
      author: 'Tom Coleman', 
      url: 'http://docs.meteor.com'
    });
    
    Browser console

    ////

    Adding posts via the console
    Adding posts via the console

    ////

    የDOM ለውጦችን መመርመር

    ////

    ////

    ስብስቦችን ማገናኘት፤ ስርጭቶች እና ደበኝነቶች

    ////

    ////

    $ meteor remove autopublish
    

    ////

    ////

    ////

    Meteor.publish('posts', function() {
      return Posts.find();
    });
    
    server/publications.js

    ////

    Meteor.subscribe('posts');
    
    client/main.js

    ኣከማች 4-4

    Removed `autopublish` and set up a basic publication.

    ////

    መደምደሚያ

    ////