LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-04-2017, 01:19 PM   #1
istabraq
LQ Newbie
 
Registered: Nov 2016
Posts: 11

Rep: Reputation: Disabled
Unhappy


I`M Using node.js.. i want to time to live connection
but this error will show:
TypeError: Cannot read property 'ensureIndex' of undefined

the code
Code:
var MongoClient = require('mongodb').MongoClient;
var mongodbURI = 'mongodb://localhost:27017/ex1';
var startDate = new Date();

MongoClient.connect(mongodbURI,setupCollection);

function setupCollection(err, db) {
  if(!err) {
    console.log("We are connected");
    collection=db.collection("test1");
db.test1.ensureIndex( { "createdAt": 1 }, { expireAfterSeconds: 300 } )
  
db.test1.insert({
   "createdAt": new Date(),
   "logEvent": 5,
   "logMessage": "Error!"
})
            }
}

Last edited by istabraq; 01-06-2017 at 10:24 AM.
 
  


Reply



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
LXer: Publisher 'DRMs' Physical Legal Textbook About 'Property,' Undermines Property And First Sale LXer Syndicated Linux News 0 05-08-2014 07:11 AM
TypeError: list indices must be integers felix001 Programming 1 12-27-2010 08:52 AM
LXer: "Intellectual Property" a Violation of Real Property LXer Syndicated Linux News 1 11-11-2009 05:39 AM
TypeError: rpmdb open failed Red Knuckles Fedora 8 11-05-2006 01:40 PM
How do you change the file Property from Read Only to .... Charlie Chan Linux - Newbie 1 05-16-2004 12:52 PM

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

All times are GMT -5. The time now is 07:18 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