如何清除复杂的数组并在微风中添加一个对象?

时间:2014-05-07 19:13:07

标签: breeze

所以我有一个声明如此的对象模型:

helper.addComplexType
  name: "Shift"
  dataProperties:
    end_time: "int"
    start_time: "int"
    earliest_in: "int"
    earliest_out: "int"
    latest_in: "int"
    latest_out: "int"
    in_early: "bool"
    in_late: "bool"
    out_early: "bool"
    out_late: "bool"

helper.addType
  name: 'DaySchedule'
  apiVersion: 3
  dataProperties:
    uid: "uid"
    employee_id: "int"
    day: "string"
    shifts:
      complexType: "Shift"
      hasMany: true
  navigationProperties:
    employee:
      type: "Employee"
      assoc: "DayScheduleEmployee"
      key: ["employee_id"]

现在我有一些代码可以更改其中一个实体,然后将其保存回服务器......

shiftType = entityManager.metadataStore.getEntityType("Shift");
shift = shiftType.createInstance
  start_time: moment(@start_time).unix()
  end_time: moment(@end_time).unix()
schedule.shifts.splice -1
schedule.shifts.push shift
entityManager.saveChanges()

但是,当我将其保存到服务器时," shift"在另一边最终没有数据值。这似乎来自entityManager.helper.unwrapChangedValues,它返回此复杂实体的空对象。我在创建这个复杂对象时遗漏了什么,然后将它附加到与之关联的实体上吗?

编辑:这似乎是breeze内部解开数组的方式的问题。

https://github.com/Breeze/breeze.js/issues/4

0 个答案:

没有答案