Error: There must be only one transform for every document, and transform must be after all other operations on the document.
starhoshi opened this issue · 1 comments
starhoshi commented
Code
Model:
export class Order extends Pring.Base {
@property orderAddresses: Pring.ReferenceCollection<OrderAddress> = new Pring.ReferenceCollection(this)
@property orderSKUs: Pring.ReferenceCollection<OrderSKU> = new Pring.ReferenceCollection(this)
}
export class OrderAddress extends Pring.Base {
@property order: FirebaseFirestore.DocumentReference
@property orderShops: Pring.ReferenceCollection<OrderShop> = new Pring.ReferenceCollection(this)
@property orderSKUs: Pring.ReferenceCollection<OrderSKU> = new Pring.ReferenceCollection(this)
}
export class OrderShop extends Pring.Base {
@property orderSKUs: Pring.ReferenceCollection<OrderSKU> = new Pring.ReferenceCollection(this)
}
export class OrderSKU extends Pring.Base {
}
Code:
const o = new Firebase.Order()
const orderAddress = new Firebase.OrderAddress()
orderAddress.order = o.getReference()
o.orderAddresses.insert(orderAddress)
for (let num of [0, 1, 2]) {
const orderSKU = new Firebase.OrderSKU()
const orderShop = new Firebase.OrderShop()
orderAddress.orderShops.insert(orderShop)
orderShop.orderSKUs.insert(orderSKU)
console.log('orderShop.id', orderShop.id, 'orderSKU.id', orderSKU.id)
orderAddress.orderSKUs.insert(orderSKU)
o.orderSKUs.insert(orderSKU)
}
await o.save()
上記コードの o.save()
でエラーが発生します。
複雑なモデルなのでわかりにくいのですが、
orderAddress.orderSKUs.insert(orderSKU)
o.orderSKUs.insert(orderSKU)
の2箇所をコメントアウトするとエラーが出なくなりますので、 insert あたりに問題がありそうです。
Error
Error: There must be only one transform for every document, and transform must be after all other operations on the document.