can-connect/can/merge/merge
This adds the can-connect/can/merge/merge
behavior from #238. Use it to merge can-define
with minimal changes and awareness of other connections.
To use make sure your types are configured as follows:
- Related types have an
.algebra
property that is configured withid
.
Student = DefineMap.extend({ ... });
Student.algebra = new set.Algebra(set.props.id("_id"))
- Related types that have a connection are configured with a
.connection
property that points to that connection.
Student.connection = baseMap({
Map: Student,
List: Student.List,
url: "/services/students",
name: "students"
});
- Lists of related types use
#
to point to that type:
Student.List = DefineList.extend({
"#": Student
});
- The base type is configured similar to above, and its connection has
canMergeBehavior
mixed in as follows:
var canMergeBehavior = require("can-connect/can/merge/merge");
var canMapBehavior = require("can-connect/can/map/map");
var ClassRoom = DefineMap.extend({
students: Student.List
});
ClassRoom.List = DefineList.extend({
"#": ClassRoom
});
ClassRoom.algebra = new set.Algebra({...})
ClassRoom.connection = connect([..., canMapBehavior, canMergeBehavior, ...],{
Map: ClassRoom,
List: ClassRoom.List
});