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

Example : firebase database #10

Open
starli-ai opened this issue Dec 8, 2021 · 2 comments
Open

Example : firebase database #10

starli-ai opened this issue Dec 8, 2021 · 2 comments

Comments

@starli-ai
Copy link

Excellent and strong project
I have a problem building a database of categories and products
Please give me an outlet or tips if possible

@melboudali
Copy link
Owner

Firebase Installation

  1. Create Firebase project.
  2. Go to Project settings > General > Your apps, then click Add app.
  3. Register the web app and install Firebase SDK:
npm install firebase
  1. Create .env.local file and add these env vars:
REACT_APP_APIKEY= '...'
REACT_APP_AUTHDOMAIN= '...'
REACT_APP_DATABASEURL= '...'
REACT_APP_PROJECTID= '...'
REACT_APP_STORAGEBUCKET= '...'
REACT_APP_MESSAGINGSENDERID= '...'
REACT_APP_APPID= '...'
REACT_APP_MESUREMENTID= '...'

If you don't know where to find the values you can go to Project settings > General > Your apps.

Authentication

  1. Go to Authentication > _ Sign-in method_ > Sign-in providers, then add and enable these providers:
  • Email/Password
  • Google
  • Facebook
  • GitHub
  1. Got to Authorized domains then add localhost and all the other domains.

Cloud Firestore

  1. Go to Rules and add these:
// Allow read/write access on all documents to any user signed in to the application
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId}{
    	allow get, create, update: if request.auth != null && request.auth.uid == userId;
    }
    match /Collections/{collection}{
    	allow read;
    }  }
}
  1. Create two Collection:
  • users
    Create a new collection with the id users.
  • Collections
    Create a new collection with the id Collections, every collection has two fields:
title: string;
items: {
id: number;
name: string; 
description: string;
firstImageUrl: string;
secondImageUrl :string;
thirdImageUrl: string
fourthImageUrl: string;
colors: string[]; 
size: number[]; 
newPrice: number;
oldPrice: number;
orders: number;
rate: number;
}[];

@starli-ai
Copy link
Author

starli-ai commented Dec 9, 2021 via email

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