orango icon indicating copy to clipboard operation
orango copied to clipboard

Can not have edge link have the same model for _from and _to

Open lizhuomeng71 opened this issue 6 years ago • 2 comments

Have a model like this

schema.type('edge', { from: 'Task', to: ['Task'] })

Then when using let plan = Plan.link( { Task: "2320844", Task: "2273357" } )

Get Error message, Error: Missing required "_to" for link

the reason being, Object can only have one unique property.

Noted:

This feature is necessary, for example, a Task is an parent of a Task, or a Task is following another Task.

lizhuomeng71 avatar Aug 09 '19 09:08 lizhuomeng71

Please check it. This is the closest to a real example

https://github.com/roboncode/orango/blob/master/examples/snippets/link.js

aguilera51284 avatar Aug 09 '19 16:08 aguilera51284

Hi aguilera51284,

Thanks, I think I understand the example case, the issue I have is when my edge have the same model for _from and _to.

which could be a meaningful use case, such as Person Know Person, or Task is a Parent of Task

The problem is for this case, I passed the _from and _to in a form of object, as an example let plan = Plan.link( { Task: "2320844", Task: "2273357" } ) then this object { Task: "2320844", Task: "2273357" }, has 2 same property with the same name "Task" during run time, it result as {Task: "2273357" ) which trigger this bug

Please let me know if explained it correctly

lizhuomeng71 avatar Aug 10 '19 07:08 lizhuomeng71