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

Question about how refi-app works? #71

Closed
darewreck54 opened this issue Jul 11, 2022 · 3 comments
Closed

Question about how refi-app works? #71

darewreck54 opened this issue Jul 11, 2022 · 3 comments

Comments

@darewreck54
Copy link

darewreck54 commented Jul 11, 2022

I could totally misunderstand the usage of this tool and a bit new to firestore, so please bear with me. With this tool, I should be able to visualize the data in the emulator no?

I have

  • firestore emulator running on port localhost:8003
  • Runing a golang unit test to just insert a collection and documents into the localhost:8003
  • Execute code to read from the emulator and it looks correct.
func TestPut(t *testing.T) {
	ctx := context.Background()
	//db := newFirestoreTestClient(ctx)
	//fsClient := &firestoreClient{db: db}
	//SetFirestoreClient(fsClient)
	project := "project"
	os.Setenv("FIRESTORE_EMULATOR_HOST", "localhost:8003")
	client, err := firestore.NewClient(ctx, project)

	if value := os.Getenv("FIRESTORE_EMULATOR_HOST"); value != "" {
		log.Printf("Using Firestore Emulator: %s", value)
	}

	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	_, _, err = client.Collection("users").Add(ctx, map[string]interface{}{
		"first": "Ada",
		"last":  "Lovelace",
		"born":  1815,
	})

	if err != nil {
		log.Fatalf("Failed adding alovelace: %v", err)
	}

	iter := client.Collection("users").Documents(ctx)
	for {
		doc, err := iter.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			log.Fatalf("Failed to iterate: %v", err)
		}
		fmt.Println(doc.Data())
	}

}

output

=== RUN   TestPut
2022/07/10 16:52:57 pipeline_stage_metadata_test.go:23: Using Firestore Emulator: localhost:8003
map[born:1815 first:Ada last:Lovelace]
map[born:1815 first:Ada last:Lovelace]
map[born:1815 first:Ada last:Lovelace]
map[born:1815 first:Ada last:Lovelace]
map[born:1815 first:Ada last:Lovelace]
--- PASS: TestPut (0.04s)
PASS

However, When i try to refresh the refid app tool, once i connect successfully to localhost:8003, I would expect to see the collection or documents. but i'm not seeing anything.

image

emulator firebase config:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "y"
  },
  "emulators": {
    "firestore": {
      "port": 8003
    },
    "ui": {
      "enabled": true,
      "port": 4000
    }
  },
  "functions": {
    "source": "functions"
  }
}

Am i missing something?

Thanks,
Derek

@thanhlmm
Copy link
Owner

Hi Derek,

Thanks for asking, you need to make sure both RefiApp and your test script have the same project-name , if not the app can still connect bot they are not sharing the same data

@darewreck54
Copy link
Author

Thanks!

I got thrown off at the connection screen. I didn't know it was for the Project Name for the connection. Thought it was just to name the connection type.

@thanhlmm
Copy link
Owner

Great, I have same issue before and though every project name is works on simulator

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