Currently, I'm working on a back end using Angular with Firebase as the database.
So far, everything is running smoothly and I've successfully created a controller for adding new posts.
The only issue I'm facing is that when a new post is created, Firebase generates a lengthy and random ID for it.
.controller("VideosCtrl", function(firebase, $scope, $firebaseArray) {
var ref = firebase.database().ref('posts')
$scope.groups = $firebaseArray(ref);
$scope.addgroup = function() {
$scope.groups.$add({
title: $scope.newgroupTitle,
caption: $scope.newgroupCaption,
creator: $scope.newgroupCreator,
privacy: $scope.newgroupPrivacy,
published: $scope.newgroupPublished,
})
}
I'm currently using scope to create new posts, but I would prefer to have the title used as the identifier instead of a random ID.
title: $scope.newgroupTitle,
As of now, when I create a new post, my database structure looks like this:
--mydomain
---- posts
------ RANDOM ID GENERATED
--------title
--------caption
--------creator
--------privacy
--------published
------ RANDOM ID GENERATED
--------title
--------caption
--------creator
--------privacy
--------published
----users
Instead, I would like the structure to be:
--mydomain
---- posts
------ TITLE ( same as below)
--------title
--------caption
--------creator
--------privacy
--------published
------ TITLE (same as below)
--------title
--------caption
--------creator
--------privacy
--------published
----users
If anyone has any recommendations or solutions, I would greatly appreciate it!
Thank you for your assistance!