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

Can not create object #4

Closed
zhouhao27 opened this issue Oct 18, 2019 · 6 comments
Closed

Can not create object #4

zhouhao27 opened this issue Oct 18, 2019 · 6 comments

Comments

@zhouhao27
Copy link

I created a few collections in firebase store: Posts, Comments, Tags etc and created a few corresponding components. There is no problem to save(create) Post. But when I save(create) other objects like Comment and Tag. I got the following error message:

Function Firestore.collection() requires its first argument to be of type non-empty string, but it was: undefined

Here is my code:

import React from "react";
import {
  Create,
  SimpleForm,
  TextInput,
} from "react-admin"

const CommentCreate = props => (
  <Create {...props}>
    <SimpleForm>
      <TextInput source="comment" />
    </SimpleForm>
  </Create>
);

export default CommentCreate;

The other components are doing the same thing.

Any suggestion? Thanks.

@zhouhao27
Copy link
Author

I found the issue. It works when I add this:

const trackedResources = [
  { name: 'posts', isPublic: true }, 
  { name: 'users', isPublic: true },
  { name: 'tags', isPublic: true}
]

Two questions:

  1. What is trackedResources used for?
  2. What about is I only allow to insert after user login instead of setting isPublic to false.

@rafalzawadzki
Copy link
Owner

@zhouhao27

  1. trackedResources is used to initialize the Firestore collections. This is basically a list of all collections that can be used in react-admin.
  2. Currently isPublic does not do anything, you can safely ignore it. It's a leftover from ra-data-firebase-client library I branched from.

@x5engine
Copy link

this should be added to the documentation which is a must!!! come on Rafal

@zhouhao27
Copy link
Author

zhouhao27 commented Oct 25, 2019

@rafalzawadzki Thanks for your reply. Another two questions for you:

  1. Is realtime supported? For example, I want to build channel to broadcast news.
  2. I saw your demo to upload image as base64. But I'm wondering if it's possible to upload files to firebase storage (bucket)

@rafalzawadzki
Copy link
Owner

@x5engine thank you - should definitely cover this in the documentation (as lots of other things). I'm currently swamped with other work, so it will take a while (PRs are also welcome ;))

@zhouhao27

  1. Realtime updates are unfortunately not supported, I am not even sure if it would be possible to accomplish with react-admin.
  2. Uploading to Firebase Storage is not supported, but definitely possible. I do not foresee adding support for it in any soon future though, as there are other more pressing issues to solve first :)

@gstvg
Copy link

gstvg commented Oct 28, 2019

@zhouhao27 I'm studying realtime support on #5, with ra-realtime, keep an eye.

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

4 participants