Skip to content

Database. Use '/' (or anything else) instead of '.' to navigate through the nested tree. #36

Closed
@Sediug

Description

I think this will be in the best interest for all db users and it'll prevent errors with some nested levels that may be using dots in their keys. I said "/" to copy firebase behaviour .ref('posts/' + postId + '/starCount')

It'll be nice for 1.0.

Ex in Database.get(point) :

function get(point) {
	if(point && typeof(point) === 'string') {
		var tree = point.split('.'),
			parent = goblin.db;

		for (var i = 0; i < tree.length; i++) {
			if(i !== tree.length-1) {
				if(typeof parent[tree[i]] === 'undefined') {
					// If there is no child here, won't be deeper. Return undefined
					return undefined;
				}
				parent = parent[tree[i]];
			} else {
				return parent[tree[i]];
			}
		}
	} else {
		return goblin.db;
	}
}

Activity

CodingCarlos

CodingCarlos commented on Feb 19, 2018

@CodingCarlos
Member

Cool. I used . because I've just wanted it to work. We could even move the nesting character to a configurable setting and set the default to / to be more friendly to firebase syntax.

Sediug

Sediug commented on Feb 19, 2018

@Sediug
MemberAuthor

Cool. Agree .

Sediug

Sediug commented on Feb 19, 2018

@Sediug
MemberAuthor

If we all agree I'd say this may be a good feature to have in https://github.com/GoblinDBRocks/GoblinDB/milestone/3

added this to the v.0.1.0 milestone on Mar 4, 2018
added a commit that references this issue on Mar 11, 2018

Merge pull request #42 from trigoporres/master

a5ebc7c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Database. Use '/' (or anything else) instead of '.' to navigate through the nested tree. · Issue #36 · GoblinDBRocks/GoblinDB