我应该进一步非规范化吗?

时间:2015-06-16 16:38:27

标签: firebase firebase-realtime-database angularfire nosql

我正在处理消息传递应用。我希望能够显示发件人用户名。我目前正在为消息和用户建模,并尝试通过authData.uid查询usersRef来显示用户名。

Messages { 
  sender: authData.uid,
  body: decoded,
  created_at: Firebase.ServerValue.TIMESTAMP
  }

Users {
  email: user.email,
  username: user.username,
  created_at: Firebase.ServerValue.TIMESTAMP
}
// This returns https://talklah.firebaseio.com/users/simplelogin%3A3/email
$scope.getUsername = function(sender) {
  var usersRef = ref.child("users");
  return usersRef.child(sender).child('email');
}

// I want to display something like this in my templates
message: Hey, how are you? (sent by [username])

我该如何处理这样的问题?

0 个答案:

没有答案