1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package repo
- import "mats/db/model"
- func GetDatabaseCollection(ctx *RepoSession, dbId string, assetId string) (db *model.Database, assetConf *model.DbAsset) {
- database := &model.Database{}
- ok, _ := RepoSeachDoc(ctx, &DocSearchOptions{CollectName: CollectionDatabase, Query: Map{"_id": dbId}, Project: []string{"assets", "name", "categories"}}, database)
- if !ok {
- return
- }
- db = database
- for _, v := range database.Assets {
- if v.Id == assetId {
- assetConf = v
- break
- }
- }
- return
- }
- func GetDatabaseCollectionSimple(ctx *RepoSession, dbId string, assetId string) *model.AssetDbConf {
- out := &model.AssetDbConf{}
- database := &model.Database{}
- ok, _ := RepoSeachDoc(ctx, &DocSearchOptions{CollectName: CollectionDatabase, Query: Map{"_id": dbId}, Project: []string{"assets", "name"}}, database)
- if !ok {
- return nil
- }
- out.Db = database
- find := false
- for _, v := range database.Assets {
- if v.Id == assetId {
- out.AssetConf = v
- find = true
- break
- }
- }
- if find {
- return out
- }
- return nil
- }
- func RepoCreateDefaultAssetValue(asset *model.DbAsset) interface{} {
- switch asset.Type {
- case model.AssetTypeMesh:
- return &model.AssetStaticMesh{}
- }
- return nil
- }
|