project.go 355 B

123456789101112131415161718
  1. package repo
  2. import (
  3. "mats/db/model"
  4. "go.mongodb.org/mongo-driver/bson/primitive"
  5. )
  6. func AddProject(ctx *RepoSession, d *model.Project) (string, error) {
  7. coll := ctx.Client.GetCollection(CollectionProject)
  8. result, err := coll.InsertOne(ctx.Ctx, d)
  9. if err != nil {
  10. return "", err
  11. }
  12. return result.InsertedID.(primitive.ObjectID).Hex(), nil
  13. }