Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = function(connect) {

db.
collection(options.collection).
ensureIndex({ expires: 1 }, { expireAfterSeconds: 0 }, function(error) {
createIndex({ expires: 1 }, { expireAfterSeconds: 0 }, function(error) {
if (error) {
var e = new Error('Error creating index: ' + error.message);
return _this._errorHandler(e, callback);
Expand Down
16 changes: 8 additions & 8 deletions test/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('connectMongoDBSession', function() {
beforeEach(function() {
db = strawman({
collection: { argumentNames: ['collection'], chain: true },
ensureIndex: { argumentNames: ['index', 'options', 'callback'] },
createIndex: { argumentNames: ['index', 'options', 'callback'] },
findOne: { argumentNames: ['query', 'callback'] },
remove: { argumentNames: ['query', 'callback'] },
update: { argumentNames: ['query', 'update', 'options', 'callback' ] }
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('connectMongoDBSession', function() {
it('specifying options is optional', function(done) {
var SessionStore = connectMongoDBSession({ Store: StoreStub });
var numIndexCalls = 0;
db.ensureIndex.on('called', function(args) {
db.createIndex.on('called', function(args) {
assert.equal(++numIndexCalls, 1);
assert.equal(args.index.expires, 1);
args.callback();
Expand All @@ -84,7 +84,7 @@ describe('connectMongoDBSession', function() {
it('uses default options and no callback if no args passed', function(done) {
var SessionStore = connectMongoDBSession({ Store: StoreStub });
var numIndexCalls = 0;
db.ensureIndex.on('called', function(args) {
db.createIndex.on('called', function(args) {
assert.equal(++numIndexCalls, 1);
assert.equal(args.index.expires, 1);
args.callback();
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('connectMongoDBSession', function() {
it('handles index errors', function(done) {
var SessionStore = connectMongoDBSession({ Store: StoreStub });
var numIndexCalls = 0;
db.ensureIndex.on('called', function(args) {
db.createIndex.on('called', function(args) {
assert.equal(++numIndexCalls, 1);
assert.equal(args.index.expires, 1);
args.callback(new Error('Index fail'));
Expand All @@ -151,7 +151,7 @@ describe('connectMongoDBSession', function() {
beforeEach(function() {
numIndexCalls = 0;

db.ensureIndex.on('called', function(args) {
db.createIndex.on('called', function(args) {
assert.equal(++numIndexCalls, 1);
assert.equal(args.index.expires, 1);
args.callback();
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('connectMongoDBSession', function() {
beforeEach(function() {
numIndexCalls = 0;

db.ensureIndex.on('called', function(args) {
db.createIndex.on('called', function(args) {
assert.equal(++numIndexCalls, 1);
assert.equal(args.index.expires, 1);
args.callback();
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('connectMongoDBSession', function() {
beforeEach(function() {
numIndexCalls = 0;

db.ensureIndex.on('called', function(args) {
db.createIndex.on('called', function(args) {
assert.equal(++numIndexCalls, 1);
assert.equal(args.index.expires, 1);
args.callback();
Expand Down Expand Up @@ -419,7 +419,7 @@ describe('connectMongoDBSession', function() {
beforeEach(function() {
numIndexCalls = 0;

db.ensureIndex.on('called', function(args) {
db.createIndex.on('called', function(args) {
assert.equal(++numIndexCalls, 1);
assert.equal(args.index.expires, 1);
args.callback();
Expand Down