12345678910111213141516171819202122 |
- package repo
- import (
- "mats/db/model"
- "go.mongodb.org/mongo-driver/bson/primitive"
- )
- func MaterialGetById(ctx *RepoSession, id string, project []string) *model.Material {
- eid, _ := primitive.ObjectIDFromHex(id)
- option := DocSearchOptions{
- CollectName: CollectionMaterials,
- Query: Map{"_id": eid},
- Project: project,
- }
- entity := &model.Material{}
- ok, err := RepoSeachDoc(ctx, &option, entity)
- if err != nil || !ok {
- return nil
- }
- return entity
- }
|