Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


Closed Thread
  Search this Thread
Old 01-06-2017, 08:06 AM   #1
LQ Newbie
Registered: Nov 2016
Posts: 11

Rep: Reputation: Disabled
Question Node.js and MangoDB with collection.update and TTL (Time To Live) not working

Please help, Kindly, how can i used node.js and mongoDB with "collection.update" with TTL (Time To Live) i tried some ideas but it does not work. the first code is mqtt node.js with mongoDB and works fine
var mqtt = require('mqtt');
var MongoClient = require('mongodb').MongoClient;
var client;
var collection;
var mongodbURI = 'mongodb://localhost:27017/exampleDb4';
var deviceRoot = '#';
var key;


function setupCollection(err, db) {
  if(!err) {
    console.log("We are connected");
    client  = mqtt.connect('mqtt://');

    client.on('message',  function (topic, message) {


   { _id:key }, 
   { $push: { events: { event: {  value:message, when:new Date() } } } }, 
   { upsert:true },

   function(err,docs) {  
   if(err) {
      console.log("Insert fail")        
i tried to put this line in the code but it does not work to expire the collections.. Thanks in advance

b.collection("test_mqtt").createIndex( { "when": 1 }, { expireAfterSeconds: 10 } )
Old 01-06-2017, 10:19 AM   #2
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Duplicate reported.
Old 01-06-2017, 10:27 AM   #3
LQ Newbie
Registered: Nov 2016
Posts: 11

Original Poster
Rep: Reputation: Disabled
Originally Posted by Habitual View Post
Duplicate reported.
i have changed a little bit with my previous question.. and i dont know how to remove the previous one ?

Closed Thread

node.js, ttl

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
TTL modification not working in DDWRT router Littleolme Linux - Networking 13 04-28-2017 04:13 PM
ping with even number ttl always return "Time to live exceeded" yafrank Linux - Networking 4 02-12-2012 02:30 AM
wrong ttl time for dns entries on bind 9.7 with suse 11.4 server marb84 Linux - Networking 4 08-31-2011 04:24 AM
Device Node Change time to time issen007 Linux - General 0 01-22-2010 07:53 AM
LXer: Real-time garbage collection with Real-time Java LXer Syndicated Linux News 0 05-05-2007 12:16 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:30 AM.

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