qnipp / meteor-treeview

This is a Blaze template to be used to display a tree (using jsTree) right from a collection.
MIT License
9 stars 8 forks source link

DB structure #4

Closed valorloff closed 7 years ago

valorloff commented 7 years ago

Hi! is it correct database structure for your TreeView?:

Schemas.Categories = new SimpleSchema({
img: {type: String},
name: { type: String},
description: {type: String},
parent: {type: String   },
categoriesId: {type: Number}
});

Is it just parentId enough?

fknipp commented 7 years ago

Hello!

Yes, the parent field containing the _id of the parent is just enough to form the tree.

If you want to set the icon used in the tree, you must use the icon field (not img), the name field should be named text.

Maybe, I should improve the documentation ;)

valorloff commented 7 years ago

Thank for quick response! And what about if i write:

"mapping": {
      "text" : "name",
      "icon" : "img"

then i can remain "name","img" fields in Categories? I don't want to spoil the DB because tree..

fknipp commented 7 years ago

Yes, this is absolutely correct.