TypeError: collection.setParent is not a function
at User.Base._init (node_modules/pring/src/pring.js:97:32)
at User.<anonymous> (node_modules/pring/src/pring.js:231:34)
at step (node_modules/pring/src/pring.js:32:23)
at Object.next (node_modules/pring/src/pring.js:13:53)
at node_modules/pring/src/pring.js:7:71
at new Promise (<anonymous>)
at __awaiter (node_modules/pring/src/pring.js:3:12)
at User.Base.save (node_modules/pring/src/pring.js:226:20)
at Context.<anonymous> (test/order.test.ts:62:24)
at Generator.next (<anonymous>)
at fulfilled (test/order.test.ts:6:32)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
Code
export class User extends Pring.Base {
keyValue: { [id: string]: string }
}
const user = new User(authUser.uid)
user.keyValue = {key: 'value'}
user.save() // => TypeError: collection.setParent is not a function
Error
Code
JSON の keyValue 形式だと
typeof value === "object"
が true になってしまい https://github.com/1amageek/pring.ts/blob/master/pring.ts#L106 でエラーになりました。ここを
if (value instanceof ReferenceCollection || value instanceof NestedCollection)
に変えたところ L106 はうまくいきましたが、今度は https://github.com/1amageek/pring.ts/blob/master/pring.ts#L191 でcollection.value is not a function
になります。typeof value === "object"
の判定方法がよくなさそうです。