LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-02-2017, 01:03 AM   #1
istabraq
LQ Newbie
 
Registered: Nov 2016
Posts: 11

Rep: Reputation: Disabled
Unhappy MongoDB- TTL doesn`t remove documents?


I`m using MongoDB with Node.js

the code:
Code:
var mqtt = require('mqtt');
var MongoClient = require('mongodb').MongoClient;
var client;
var collection;
var mongodbURI = 'mongodb://localhost:27017/ex3';
var deviceRoot = '#';
var key;

MongoClient.connect(mongodbURI,setupCollection);
  
function setupCollection(err, db) {
  if(!err) {
    console.log("We are connected");
    collection=db.collection("new2");
    client  = mqtt.connect('mqtt://192.168.0.132');
    client.subscribe(deviceRoot);
   
    client.on('message',  function (topic, message) {
    console.log(message.toString());


   key=topic.replace(deviceRoot,'');

   collection.update(
   { _id:key }, 
   { $push: { events: { event: {  value:message, when:new Date(), expireAfterSeconds: 10 } } } },
    
   { upsert:true },

   function(err,docs) {  
   if(err) {
      console.log("Insert fail")		
	   }
                       }
                   );
                                                    })
           }
                                  }
but the documents will never remove!
help please?
 
  


Reply

Tags
node.js, ttl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu 8.10 doesn't print documents containing some characters Ian B Christie Linux - Hardware 1 04-21-2009 06:31 AM
Documents saved as MS Word documents Raggety Linux - Software 2 01-14-2009 02:16 PM
apt-get remove chrony doesn't remove all? asgerhallas Debian 3 06-05-2007 05:37 AM
apt-get remove doesn't work Yukon Linux - General 5 12-10-2006 11:40 PM
rm doesn't prompt for whether to remove the file :( Dragons Master Linux - Newbie 6 05-05-2006 06:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 05:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration