使用AngularFire,是否有可能创建关系式数据库?或访问UniqueIDs? [英] Using AngularFire, is it possible to to create relational-style databases? Or access the UniqueIDs?

查看:133
本文介绍了使用AngularFire,是否有可能创建关系式数据库?或访问UniqueIDs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到在火力地堡的这个帖子博客解释使用自己的平台来创建关系数据对象的最佳方式。我挣扎翻译这些概念AngularFire,它们的集成与AngularJS平台。

I saw this post on Firebase's blog explaining the best way to create relational data objects using their platform. I'm struggling to translate these concepts to AngularFire, their integration with the AngularJS platform.

具体来说,我想显示具有相似的他们是如何描述它在这个例子中,从他们的岗位单向指针引用关联的数据集:

Specifically, I'm trying to display two linked data sets that have a one way pointer reference similar to how they described it in this example from their post:

var commentsRef = new Firebase("https://awesome.firebaseio-demo.com/comments");
var linkCommentsRef = new Firebase("https://awesome.firebaseio-demo.com/links/comments");

linkCommentsRef.on("child_added", function(snap) {
     commentsRef.child(snap.name()).once("value", function() {
         // Render the comment on the link page.
     ));
});

问:是否有可能与当前AngularFile整合,使指针样式引用到其它数据对象?如果是这样,你能提供一个例子?

Question: Is it possible with the current AngularFile integration to make the pointer-style references to other data objects? And if so, can you provide an example?

编辑:我觉得我能解决这些问题,如果我可以访问的唯一ID 按AngularFire我的数据生成[见下文]。我如何访问它们?

I feel like I'd be able to solve these problems if I can just access the unique IDs generated by AngularFire for my data [see below]. How do I access them?

推荐答案

问得好!

您确实需要访问的唯一ID,我们最近增加了一个功能,可以让你通过 angularFireCollection 访问它:的 https://github.com/firebase/angularFire/pull/26

You do need access to the unique IDs, and we recently added a feature that will give you access to it via angularFireCollection: https://github.com/firebase/angularFire/pull/26.

如果您使用的是隐式同步方法( angularFire ),那么你已经有了访问密钥,只要你指定要定了型的第四个参数收集到'对象'的:

If you're using the implicit sync method (angularFire), then you already have access to the keys as long as you specify the 4th argument that will set the type of the collection to 'Object':

function MyController($scope, angularFire) {
  var url = 'https://awesome.firebaseio-demo.com/comments';
  var promise = angularFire(url, $scope, 'comments', {});
  promise.then(function() {
    var id = '-lw2NDTiZMFvzEWmSnYn';
    console.log($scope.comments[id]);
  });
}

希望这有助于!

这篇关于使用AngularFire,是否有可能创建关系式数据库?或访问UniqueIDs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆