1amageek/pring.ts

Nested ReferenceCollections are not saved

starhoshi opened this issue · 1 comments

class POrder extends Pring.Base {
  // user: Reference<PringUser>
  amount: number
  orderAddresses: Pring.ReferenceCollection<POrderAddress> = new Pring.ReferenceCollection(new POrderAddress())
}

class POrderAddress extends Pring.Base {
  amount: number
  orderShops: Pring.ReferenceCollection<POrderShop> = new Pring.ReferenceCollection(new POrderShop())
}

class POrderShop extends Pring.Base {
  amount: number
  orderSKUs: Pring.ReferenceCollection<POrderSKU> = new Pring.ReferenceCollection(new POrderSKU())
}

class POrderSKU extends Pring.Base {
  quantity: number
}
    const orderSKU = new POrderSKU()
    orderSKU.quantity = 1

    const orderShop = new POrderShop()
    orderShop.amount = 1000
    orderShop.orderSKUs.insert(orderSKU)

    const orderAddress = new POrderAddress()
    orderAddress.amount = 1000
    orderAddress.orderShops.insert(orderShop)

    const order = new POrder()
    order.amount = 1000
    order.orderAddresses.insert(orderAddress)

    order.save()

order, orderAddress, orderShop, orderSKU が同時に保存されると思ったのですが、
保存されたのは order, orderAddress だけでした 😢

fixed this issue, thanks!

ref: 7427689