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

Doc.data () does not set values ​​in additional fields #13

Open
onota0318 opened this issue Apr 5, 2020 · 4 comments
Open

Doc.data () does not set values ​​in additional fields #13

onota0318 opened this issue Apr 5, 2020 · 4 comments

Comments

@onota0318
Copy link

※All are translated from Japanese into English by Google Translate.

Maybe my usage is wrong...

Description

Expection

If you pass the value to Field and call save () method, the value is registered in firestore field

  • field
import "reflect-metadata";
import { Field, Doc } from "@1amageek/ballcap";

export class Product extends Doc {
    @Field 
    public providerType: string;
}
  • CRUD Logic
    const product = new Product();
    product.providerType = "ABC";
    await product.save();
  • firestore results

results

actual field providerType is null・・・

Question

Doc.data() is got the following results.

Object {
  "configurable": true,
  "enumerable": true,
  "value": "ABC",
  "writable": true,
}

https://github.com/1amageek/ballcap.ts/blob/master/web/src/Model.ts#L90

descripter.get isn't applicable.

It works as expected.

//            if (descriptor && descriptor.get) {
            if (descriptor && descriptor.get) {
                const value = descriptor.get();
                data[codingKey] = this._encode(value, option);
            }
★            else if (descriptor && descriptor.value) {
                data[codingKey] = this._encode(descriptor.value, option);
            }

I have no idea if my usage is wrong or if I need to modify the library...

@1amageek
Copy link
Owner

1amageek commented Apr 6, 2020

@onota0318 Thank you for your message.

I think there is a problem in your tsconfig.json.
If you are using webpack, try the readme settings.

@onota0318
Copy link
Author

@1amageek

Thank you for your reply.
I am using Expo this time and refer to example/with-expo

expo : 36.0.2

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "jsx": "react-native",
    "target": "esnext",
    "lib": ["dom", "esnext"],
    "moduleResolution": "node",
    "module": "commonjs",
    "noEmit": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": "./",
    "paths": {
      "@Config/*": ["./src/config/*"],
                   〜
    },
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

babel.config.js

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      [
        "module-resolver",
        {
          root: ["./"],
          alias: {
            "@Config": "./src/config",
                   〜
          },
        },
      ],
    ],  
  };
};

I am check the configuration again.

@1amageek
Copy link
Owner

1amageek commented May 5, 2020

@onota0318 連絡遅れてすみません。
日本語でいいですよ!

今の環境はReactですか?

@onota0318
Copy link
Author

@1amageek
(日本語だと大変助かります・・・ありがとうございます😂)

今の環境は ReactNative(expo) です!

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

2 participants