עזרה בfirebase - תכנות - HWzone פורומים
עבור לתוכן
  • צור חשבון

עזרה בfirebase


יוסי גריינימן
 Share

Recommended Posts

 

 

1681919168052-0e7dd27b-77a7-41ac-9efe-a4aa610b644b-image.png.f10bf53a59d7187a8fa2671ba0648d9e.png

 

 

1681919241489-07f6ee50-501b-4fa8-9f48-82c83db1a053-image.png.611069168f902b0a650658afb083fbd1.png

 

וכל זה ב7-8 הכי הרבה 10

//servise אנגולר
import {Injectable} from '@angular/core';
import {AngularFirestore} from '@angular/fire/compat/firestore';
import {catchError} from 'rxjs/operators';
import {throwError} from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class DataService
{
  videos: any[] = []
  errorVideos: any = false
  users: any = false

  constructor (private firestore: AngularFirestore)
  {
    this.getvideos();
  }

  getvideos ()
  {

    if (this.videos.length === 0 && !this.errorVideos)
    {
      this.firestore.collection('videos')
        .valueChanges()
        .pipe(
          catchError(error =>
          {
            this.errorVideos = {
              text: error.message
            }
            if (localStorage.getItem('videos') != null)
            {
              let string: any = localStorage.getItem('videos')

              this.videos = JSON.parse(string)

              this.errorVideos.timevideos = localStorage.getItem('timevideos')

              console.log(this.videos)
            }
            return throwError(error);
          })
        )
        .subscribe(data =>
        {
          this.videos = data;

          console.log(this.videos)

          let string = JSON.stringify(this.videos)
          localStorage.setItem('videos', string)
          localStorage.setItem('timevideos', '' + new Date().getTime())
        });
    }
  }
}

ובמילים פשוטות בconstrctor(בנאי מופעל ברגע הראשון)
יש קריאה ל
this.getvideos();
ששולח קריאה לfirebase לקבל את כל הcollection
( this.firestore.collection('videos')
.valueChanges())
ולשמור אותו במשתנה videos וכל זה רק במקרה שעדיין הוא ריק (כי יש כמה מקומות שמשתמשים בservise הזה)
(כל מה שלפני הsubscribe זה טיפול בשגיאות)

מספר פעמים רעננתי את הדף (כי הרי הוא לא יקרא לנתונים פעמים באותו כניסה)
ואחרי מספר פעמים
התמונות למעלה

תגובת הקונסול
ROR FirebaseError: Quota exceeded.
h

בקולקשן (collection) videos יש 3579 אובייקטים שמכילים

date סטרינג
id סטרינג
img אוביקט עם url , אורך ורוחב כולם סטירינג (רוחב ואורך מספר)
name סטרינג
text סטרינג
userid סטרינג

אבל בfirebase זה נראה כאילו קראתי יותר מ50000 (50k) פעם
יכול להיות שזה לפי אוביקט ולא לפי קריאה ?

קישור לתוכן
שתף באתרים אחרים

הצטרפ/י לדיון

בשלב זה תוכל/י להצטרף לדיון, ולאחר מכן להצטרף לקהילה שלנו. אם כבר יש לך חשבון אצלנו, אנא התחבר/י עכשיו על מנת להגיב תחת שם המשתמש שלך.
לתשומת לבך: התגובה תופיע לגולשים לאחר אישור של צוות הנהלת הפורומים.

אורח
הוסף תגובה

×   התוכן שהודבק הוא עם עיצוב.   הסר עיצוב

  Only 75 emoji are allowed.

×   הקישור שלך הוטמע אוטומטית.   הצג כקישור רגיל

×   התוכן הקודם שלך שוחזר אוטומטית.   נקה הכל

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
  • צור חדש...