使用 AngularFire,是否可以创建关系式数据库?或者访问 UniqueIDs?

编程入门 行业动态 更新时间:2024-10-26 23:29:54
本文介绍了使用 AngularFire,是否可以创建关系式数据库?或者访问 UniqueIDs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我看到 .

如果您使用的是隐式同步方法 (angularFire),那么只要您指定将集合类型设置为Object"的第 4 个参数,您就已经可以访问这些键了':

function MyController($scope, angularFire) {var url = 'https://awesome.firebaseio-demo/comments';var promise = angularFire(url, $scope, 'comments', {});承诺.然后(功能(){var id = '-lw2NDTiZMFvzEWmSnYn';console.log($scopements[id]);});}

希望这会有所帮助!

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/comments");
var linkCommentsRef = new Firebase("https://awesome.firebaseio-demo/links/comments");

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

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?

Edit: 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?

解决方案

Great question!

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/firebase/angularFire/pull/26.

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/comments';
  var promise = angularFire(url, $scope, 'comments', {});
  promise.then(function() {
    var id = '-lw2NDTiZMFvzEWmSnYn';
    console.log($scopements[id]);
  });
}

Hope this helps!

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

更多推荐

[db:关键词]

本文发布于:2023-04-22 11:20:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023051.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:关系式   数据库   AngularFire   UniqueIDs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!