Skip to content

How to generate a individual feed user with Node.js and Firebase Realtime Database

Notifications You must be signed in to change notification settings

pdrozz/post_feed_nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

How to generate a custom feed to much users

How to generate a individual feed user with Node.js, Firebase Realtime Database and Firebase Functions

Similar with instagram feed. It's a trigger to Firebase Realtime Database to create a feed

Example

const globaltime=999999999999999;
                             //The ref from users create a new posts
exports.genereteFeed = functions.database.ref('/posts/{IDuser}/posts/{IDpost}')
.onCreate((snap,context)=>{

    let idUser=context.params.IDuser;
    let idPost=context.params.IDpost;
    
                                //on child_added return the list of followers one a one
    const followers = db.ref(`followers/${iduser}/followers/`)
    .on('child_added',function(params) {
      var snapShotFollower = params.val();
      var idFollower=snapShotFollower.id;
    
      //The ref where the script will create a individual feed
      var feedref=db.ref(`feed/${idFollower}/feed`);
      
      //save the data
      feedref.child(idPost).set(
        {
          idPost:idPost,
          idAuthor:idUser,
          date:globaltime-Date.now()      
      })
    });

  })

About

How to generate a individual feed user with Node.js and Firebase Realtime Database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published