1amageek / pring.ts

Cloud Firestore model framework for TypeScript - Google
https://firebase.google.com/docs/firestore/
MIT License
108 stars 7 forks source link

Collection count is reset when model saved #9

Closed starhoshi closed 6 years ago

starhoshi commented 6 years ago
export class Cart extends Pring.Base {
  @property cartSKUs: Pring.NestedCollection<CartSKU> = new Pring.NestedCollection(this)
}

export class CartSKU extends Pring.Base {
  @property quantity: number
}
    const cart = new Firebase.Cart()

    const cartSKU1 = new Firebase.CartSKU()
    cartSKU1.quantity = 1

    cart.cartSKUs.insert(cartSKU1)
    console.log(cart.cartSKUs.count()) // => 1

    await cart.save()
    console.log(cart.cartSKUs.count()) // => 0