Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NestedCollection's forEach is not working #10

Open
starhoshi opened this issue Dec 22, 2017 · 1 comment
Open

NestedCollection's forEach is not working #10

starhoshi opened this issue Dec 22, 2017 · 1 comment

Comments

@starhoshi
Copy link
Contributor

starhoshi commented Dec 22, 2017

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()
      cart.init(cartSnapshot)

      console.log(cart.cartSKUs.objects) // => []
      cart.cartSKUs.forEach(c => {
        console.log('c.id', c.id)
      })

      const cartSKUs = await cart.cartSKUs.getReference().get().then(s => s.docs)
      cartSKUs.forEach(c => {
        console.log(c.id) // => logged cartSKU id
      })

Collection の forEach を実行しても、 objects が [] なので for が周りません。
firestore を直で叩くと cartSKU 情報は取得できているので、情報は存在します。

@starhoshi starhoshi changed the title Collections's forEach is not working NestedCollection's forEach is not working Dec 22, 2017
@starhoshi
Copy link
Contributor Author

      const cartSKUs: Firebase.CartSKU[] = await cart.cartSKUs.getReference().get().then(s => {
        return s.docs.map(doc => {
          const cartSKU = new Firebase.CartSKU()
          cartSKU.init(doc)
          return cartSKU
        })
      })

クライアント側でこれをやればいいので pring.ts 側でサポートする必要はない気がしてきた 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant