MongoDB
 sql >> база данни >  >> NoSQL >> MongoDB

Разработете схема на база данни за Notify like facebook

router.post('/index/likestatus', function(req, res, next) {
    // Get form values   
    var username = req.user.username; //get the username from the sessions get current username who is login 
   var name = req.user.name; //same as above line this time get name of user
    var like = {
             "name" : name,
            "username": username
            };// my like is embedded to every status or post store who like this status

        Status.update({
                "_id": req.body.iid //this is status id or post id ...replace status with post in yours case 
            },
            {
                $push:{
                    "likes": like
                }//this $push save the newlike in collection 
            },
            function(err, doc) {
                if(err) {
                    throw err
                } else {
var newnotification = new notification
({postid:req.body.iid,,type:'like',uid:req.user.username,link:'yourlocalhost/'+post_id}).save(function (err) {
                console.log(username+' has posted a new status');
                    res.send({status:'success'});
                }
            }
        );//this save function save new notifications for a user the collection is similar to your req.body.iid is get from form u submit and its status id ,uid:req.user.username you store username in uid as i say username is _id or primary key
    });



  1. Redis
  2.   
  3. MongoDB
  4.   
  5. Memcached
  6.   
  7. HBase
  8.   
  9. CouchDB
  1. Грешка [ERR_HTTP_HEADERS_SENT]:Не могат да се задават заглавки, след като са изпратени на клиента

  2. Отмяна на драйвера MongoDB c# Стойност по подразбиране на низ от null на string.empty

  3. Как да приложите атрибут BsonRepresentation по конвенция, когато използвате MongoDB

  4. MongoDB + nodejs:как да потърся заявка за полетата на ISODate?

  5. Mongodb:връща съответстващи филтри при използване на $or в find()