Skip to content

iris-contrib/sessiondb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sessiondb

Go Report

Dgraph & MongoDB stores for sessions of kataras/iris.

How to use

Full examples can be found in the examples folder.

Mongo

Mongo Reference

To include mongostore run

go get github.com/iris-contrib/sessiondb/mongostore

Example

	// replace with your running mongo server settings:
	cred := options.Credential{
		AuthSource: "admin",
		Username:   "user",
		Password:   "password",
	}

	clientOpts := options.Client().ApplyURI("mongodb://127.0.0.1:27017").SetAuth(cred)
	db, _ := mongostore.New(clientOpts, "sessions")

	sess := sessions.New(sessions.Config{Cookie: "sessionscookieid"})

	sess.UseDatabase(db)

Dgraph

Dgraph Reference

To include dgraphstore run

go get github.com/iris-contrib/sessiondb/dgraphstore

Example

	// replace with your server settings:
	conn, _ := grpc.Dial("127.0.0.1:9080", grpc.WithInsecure())
	db, _ := dgraphstore.NewFromDB(conn)

	sess := sessions.New(sessions.Config{Cookie: "sessionscookieid"})

	sess.UseDatabase(db)

Contribute

Development of each store is done on branches. If you plan to work with an existing store checkout the corresponding branch. If you intent to implement a new store then create a new branch named after the DB you are using.

The repository is using go-submodules. The rationale behind this optimisation is for user to avoid downloading unnecessary drivers/libraries but keep the maintenance tight and clean.

For releasing a new version of each individual store (submodule) you need to

  1. merge from corresponding branch to main
  2. tag with appropriate store name and particular store's version ie. git tag mongostore/v0.1.1