func (a *Application) Save() error {
	if a.ID == "" {
		return a.Create()
	}
	session := db.GetSession()
	defer session.Close()
	c := getApplicationsCollection(session)
	if err := c.Update(bson.M{"_id": a.ID}, bson.M{"$set": a}); err != nil {
		return fmt.Errorf("Unable to save application: %s", err)
	}
	return nil
}
Save saves user entity in db
package entities
import (
	"fmt"
	"github.com/dokkur/swanager/config"
	"github.com/dokkur/swanager/core/db"
	"github.com/dokkur/swanager/lib"
	mgo "gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)
const applicationsCollectionName = "applications"
type Application struct {
	ID         string    `json:"id" bson:"_id,omitempty"`
	Name       string    `json:"name"`
	UserID     string    `json:"-" bson:"user_id"`
	Services   []Service `json:"services,omitempty" bson:"-"`
	ServiceIDS []string  `json:"service_ids,omitempty" bson:"-"`
}
func GetApplications(params map[string]interface{}) ([]Application, error) {
	session := db.GetSession()
	defer session.Close()
	c := getApplicationsCollection(session)
	applications := make([]Application, 0)
	if err := c.Find(params).All(&applications); err != nil {
		return nil, err
	}
	return applications, nil
}
func GetApplication(params map[string]interface{}) (*Application, error) {
	session := db.GetSession()
	defer session.Close()
	c := getApplicationsCollection(session)
	application := Application{}
	if err := c.Find(params).One(&application); err != nil {
		return nil, fmt.Errorf("GetApplication error: %s", err)
	}
	return &application, nil
}