angularfirebase和typescript-设置数据库返回值的类型

时间:2019-06-18 13:03:47

标签: angular typescript firebase firebase-realtime-database

我有此功能

MONGO_URI = "mongodb://localhost:27017/portal_db"

tab_schema = {
    "schema": {
        "var0030":{"type": "integer"},
        "var0053":{"type": "integer"},
        "var0052":{"type": "integer"},
        "var0058":{"type": "integer"},
        "var0054":{"type": "integer"},
        "var0055":{"type": "integer"},
        "var0046":{"type": "string"},
        "var0057":{"type": "integer"},
        "var0028":{"type": "string"},
        "var0029":{"type": "integer"},
        "var0059":{"type": "integer"}
    }
}

func = {
    'datasource': {
        'source': 'tab0043'
    },
    "schema": {
        "var0030":{"type": "integer"},
        "var0053":{"type": "integer"},
        "var0052":{"type": "integer"},
        "var0058":{"type": "integer"},
        "var0054":{"type": "integer"},
        "var0055":{"type": "integer"},
        "var0046":{"type": "string"},
        "var0057":{"type": "integer"},
        "var0028":{"type": "string"},
        "var0029":{"type": "integer"},
        "var0059":{"type": "integer"}
    },
    'pagination': False
}

DOMAIN = {
    "tab0043": tab_schema,
    "func": func
}

从数据库返回的值是M.UserPresence。但是,它不是编译的,因为

 getPresence(userGuid: string): Observable<M.UserPresence>{
    let firebaseRef = this.firebaseService.getFirebaseUsersDataRef('presence/' + userGuid);
    return this.db.object(firebaseRef).valueChanges();
  }

我如何“说”数据库的返回类型实际上是M.UserPresence

0 个答案:

没有答案