Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteUserByID(id string) error
- func ExistUserByID(id string) (bool, error)
- func GetSessionAndCollection(collection string) (*mgo.Session, *mgo.Collection)
- func UpdateUser(selector interface{}, user *User) error
- func UpdateUserAll(selector interface{}, user *User) (*mgo.ChangeInfo, error)
- func UpdateUserByID(id interface{}, user *User) error
- func UpdateUserByIDAndEntityMap(id interface{}, updateMap map[string]interface{}) error
- type User
Constants ¶
const (
CollectionUser = "users"
)
Variables ¶
var ( ErrorInvalidObjectId = errors.New("invalid objectId") MongoSession *mgo.Session )
Functions ¶
func DeleteUserByID ¶
func ExistUserByID ¶
func GetSessionAndCollection ¶
func GetSessionAndCollection(collection string) (*mgo.Session, *mgo.Collection)
func UpdateUser ¶
Update finds a single document matching the provided selector document and modifies it according to the update document. If the session is in safe mode (see SetSafe) a ErrNotFound error is returned if a document isn't found, or a value of type *LastError when some other error is detected.
Relevant documentation:
http://www.mongodb.org/display/DOCS/Updating http://www.mongodb.org/display/DOCS/Atomic+Operations
func UpdateUserAll ¶
func UpdateUserAll(selector interface{}, user *User) (*mgo.ChangeInfo, error)
UpdateAll finds all documents matching the provided selector document and modifies them according to the update document. If the session is in safe mode (see SetSafe) details of the executed operation are returned in info or an error of type *LastError when some problem is detected. It is not an error for the update to not be applied on any documents because the selector doesn't match.
Relevant documentation:
http://www.mongodb.org/display/DOCS/Updating http://www.mongodb.org/display/DOCS/Atomic+Operations
func UpdateUserByID ¶
Types ¶
type User ¶
type User struct { ID bson.ObjectId `bson:"_id" json:"id"` UserName string `bson:"user_name" json:"user_name,omitempty"` Email string `bson:"email" json:"email,omitempty"` Password string `bson:"password" json:"password,omitempty"` CreatedAt time.Time `bson:"created_at" json:"created_at" time_format:"2006-01-02 15:04:05"` UpdatedAt time.Time `bson:"updated_at" json:"updated_at" time_format:"2006-01-02 15:04:05"` Deleted int `bson:"deleted" json:"-"` }