resulturan / refine-firebase

MIT License
43 stars 22 forks source link

added dependency to @pankod/refine-core and adjustments to make it work with Refine latest version #6

Closed pinale closed 1 year ago

pinale commented 1 year ago

i exported some types, made some adjustments in order to use your work with the latest version of Refine!

Moreover i gave a new shape to the output of the getMany method that didn't return an array (as getList do) but, rather, it returned an object with numeric keys that cannot be used with .map(

i removed this lines from .eslint just to compile on my machine ( i suppose this lines are for some testing framework that i don't know) you restore them if needed

 "extends": [
    "kentcdodds/best-practices",
    "kentcdodds/possible-errors",
    "kentcdodds/mocha"

Please, take a look at this PR and let me know what do you think.

PS: a question for you: how did you intend save data in firebase, what is the aspected json? I've saved a structure like this:

{
  "categories": {
    "b0925c18-a201-4b67-a15c-11352195c696": {           //<---object key
      "id": "b0925c18-a201-4b67-a15c-11352195c696",     //<--- id to use in Refine
      "title": "sport"
    },
    "b0925c18-a201-4b67-a15c-11352195c697": {
      "id": "b0925c18-a201-4b67-a15c-11352195c697",
      "title": "news"
    },
    "b0925c18-a201-4b67-a15c-11352195c698": {
      "id": "b0925c18-a201-4b67-a15c-11352195c698",
      "title": "shop"
    }
  },
  "posts": {
    "50a57cf5-2e46-46cb-98fc-81e264d1bb75": {
      "category": {
        "id": "b0925c18-a201-4b67-a15c-11352195c698",
        "title": "shop"
      },
      "id": "50a57cf5-2e46-46cb-98fc-81e264d1bb75",
      "status": "draft",
      "title": "nuovo elemento"
    },
    "66cf14e6-9154-49dc-b769-977a2806463c": {
      "category": {
        "id": "b0925c18-a201-4b67-a15c-11352195c698",
        "title": "shop"
      },
      "id": "66cf14e6-9154-49dc-b769-977a2806463c",
      "status": "rejected",
      "title": "definitivo"
    },
    "8fb971ca-0330-4c2b-a0c6-14f92debc20c": {
      "category": {
        "id": "b0925c18-a201-4b67-a15c-11352195c696",
        "title": "sport"
      },
      "id": "8fb971ca-0330-4c2b-a0c6-14f92debc20c",
      "status": "published",
      "title": "con interfaccia"
    }
  }
}   
resulturan commented 1 year ago

Hi @pinale, Thanks for your contribution.

  1. I will check your PR this weekend
  2. About your data structure, you can consider to use this type for Post: { "category": "b0925c18-a201-4b67-a15c-11352195c698", "id": "50a57cf5-2e46-46cb-98fc-81e264d1bb75", "status": "draft", "title": "nuovo elemento" }
resulturan commented 1 year ago

@pinale I released a new version as v1.1.1. It is including most of your suggestions.