usermngmt/role/db.go

20 lines
428 B
Go
Raw Normal View History

2021-11-10 01:44:22 +00:00
package role
import (
"context"
2021-11-10 04:01:39 +00:00
"github.com/Selly-Modules/usermngmt/database"
"github.com/Selly-Modules/usermngmt/model"
2021-11-10 01:44:22 +00:00
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
2021-11-10 04:42:23 +00:00
func findByID(ctx context.Context, id primitive.ObjectID) (model.DBRole, error) {
2021-11-10 01:44:22 +00:00
var (
2021-11-10 02:54:49 +00:00
doc model.DBRole
2021-11-10 04:01:39 +00:00
col = database.GetRoleCol()
2021-11-10 01:44:22 +00:00
)
2021-11-10 04:01:39 +00:00
err := col.FindOne(ctx, bson.M{"_id": id}).Decode(&doc)
2021-11-10 01:44:22 +00:00
return doc, err
}