Secbone / koa-session2

Middleware for Koa2 to get/set session
MIT License
153 stars 30 forks source link

koa2 use koa-session2 how to connection mongodb #9

Closed godruoyi closed 8 years ago

godruoyi commented 8 years ago

Please help me?

Secbone commented 8 years ago

@godruoyi You can put your connection code in the constructor function of your custom store. :)

godruoyi commented 8 years ago

i whant use mongodb as session store, but i down't know how to connect it sach as :

//app.js
import session from "koa-session2";
import {Store} from "koa-session2";

......

// here, i whant use mongodb as session store, how to set it ....
app.use(session({
  key: 'settings.sessionkey',
  store: new Store()
}));
Secbone commented 8 years ago

@godruoyi You can write your class of store with extending koa-session2 store, and write you connection code in the constructor function of the store class, just like the example in README. :)