Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteUserByID(id bson.ObjectId) error
- func ExistUserByID(id bson.ObjectId) (bool, error)
- func GetUserSessionAndCollection() (*mgo.Session, *mgo.Collection)
- func UpdateUser(selector interface{}, user *User) error
- func UpdateUserAll(selector interface{}, user *User) (*mgo.ChangeInfo, error)
- func UpdateUserByID(id bson.ObjectId, user *User) error
- func UpdateUserByIDAndEntityMap(id bson.ObjectId, updateMap map[string]interface{}) error
- type User
- func GetOneUserByQuery(query map[string]interface{}) (*User, error)
- func GetUserByID(id bson.ObjectId) (*User, error)
- func ListAllUserByQuery(query map[string]interface{}) ([]*User, error)
- func ListAllUserByQueryWithOffsetAndLimit(query map[string]interface{}, offset, limit int) ([]*User, error)
- func ListAllUserByQueryWithOrder(query map[string]interface{}, offset, limit int, order ...string) ([]*User, error)
- func NewUser() *User
Constants ¶
const ( DbNameUser = "test" CollectionUser = "users" )
Variables ¶
var (
ErrorInvalidObjectId = errors.New("invalid objectId")
)
Functions ¶
func DeleteUserByID ¶
func GetUserSessionAndCollection ¶
func GetUserSessionAndCollection() (*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
Types ¶
type User ¶
type User struct { ID bson.ObjectId `bson:"_id" json:"id"` UserName string `bson:"user_name" json:"user_name,omitempty" valid:"required~first name is blank"` Email string `bson:"email" json:"email,omitempty" valid:"required,email"` Password string `bson:"password" json:"password,omitempty" valid:"required"` Ct int64 `bson:"ct" json:"ct"` Mt int64 `bson:"mt" json:"mt"` Deleted int `bson:"deleted" json:"-"` }