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

Support FirebaseFirestore.DocumentReference #19

Open
starhoshi opened this issue Jan 23, 2018 · 0 comments
Open

Support FirebaseFirestore.DocumentReference #19

starhoshi opened this issue Jan 23, 2018 · 0 comments

Comments

@starhoshi
Copy link
Contributor

starhoshi commented Jan 23, 2018

An Error occurred when I tried to save DocumentReference on Cloud Functions.

Error

Error: Cannot encode type ([object Object]) to a Firestore Value

Error: Cannot encode type ([object Object]) to a Firestore Value
    at Function.encodeValue (/user_code/node_modules/pring/node_modules/@google-cloud/firestore/src/document.js:773:11)
    at Function.encodeFields (/user_code/node_modules/pring/node_modules/@google-cloud/firestore/src/document.js:644:36)
    at Function.fromObject (/user_code/node_modules/pring/node_modules/@google-cloud/firestore/src/document.js:202:55)
    at WriteBatch.set (/user_code/node_modules/pring/node_modules/@google-cloud/firestore/src/write-batch.js:272:39)
    at PringTest.Base.pack (/user_code/node_modules/pring/src/pring.js:225:27)
    at PringTest.<anonymous> (/user_code/node_modules/pring/src/pring.js:268:42)
    at step (/user_code/node_modules/pring/src/pring.js:32:23)
    at Object.next (/user_code/node_modules/pring/src/pring.js:13:53)
    at /user_code/node_modules/pring/src/pring.js:7:71
    at __awaiter (/user_code/node_modules/pring/src/pring.js:3:12)

Code

class PringTest extends Pring.Base {
  @property testRef: FirebaseFirestore.DocumentReference
}

export const createTestOrder = functions.firestore.document(`/version/1/testorder/{testOrderID}`).onCreate(async event => {
  const pringTest = new PringTest()
  pringTest.testRef = admin.firestore().doc('/version/1/sku/test')
  await pringTest.save() // error
})
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