Error al instalar Functions de Firebase en Flutter

he intentado instalar Functions de Firebase en mi proyecto de Flutter, he seguido la documentacion de Firebase tal como se describe aqui: https://firebase.google.com/docs/functions/get-started?authuser=1

Ejecuto el comando “firebase init functions”, posterior me solicita elegir un proyecto, despues selecciono el lenguaje Javascript y por ultimo intento instalar las dependencias de NPM, es en este punto donde me sale un error.

ERR! Unexpected end of JSON input while parsing near '...0.12.0","sinon":"4.5.'

Si alguien pudiera decirme porque ocurre esto, anteriormente en otro proyecto hice lo mismo y funciono sin problemas pero ahora me sale ese error de una dependencia.

firebase – How to add map inside document in firestore using flutter?

I am using map inside array in firestore document. The problem is that when i am adding maps with new values then instead of increasing the size of array it is replacing new map with current map.
My code is look like this:

Map<String, dynamic> map = {'name': "Asad"};

RaisedButton(
    child: Text("press me"),
    onPressed: () {
      Firestore.instance.collection('Shops').document('2').setData({
        'name': 'Ali',
        'id': '3',
        'array': FieldValue.arrayUnion((map))
      });
    },
  ),

And my firestore db looks like this:

Firestore Database

How to increase the size of array or you can say how to add new element inside array instead of replacing it.Thanks in advance.

firebase – Show data from firestore two properties

I want to show data which meets the following 2 conditions:

  • The ‘done’ property is false, and
  • If ‘done’ is true, then only show today’s done items (serverTimeStamp)

How could I go about achieving this:

Currently I have the following which only returns items where ‘done’ is false.

yield* userDoc.todoCollection
        .orderBy('serverTimeStamp', descending: true)
        .snapshots()
        .map(
          (snapshot) => snapshot.documents
              .map((doc) => TodoDto.fromFirestore(doc).toDomain()),
        )
        .map(
          (todos) => right<TodoFailure, KtList<TodoItem>>(
            todos
                .where(
                  (todo) =>
                      !todo.done,
                )
                .toImmutableList(),
          ),
        )

javascript – How to get random pushed key from firebase realtime database

i am about to delete the child -MAkugTU_85UTvn4g9Hn by date(timestamp) and videoId value in folowing image

enter image description here

i tried below code only return the parent called oUi3NI9SdcbCC6v5EmygDNV4lrg1 not the random pushed key, any suggestion will be appreciated.

    const uid = firebase.auth().currentUser.uid;
    const ref = firebase.database().ref('posts').child(uid);
         ref.orderByChild('date').equalTo(date).once("value",snapshot => {
            console.log(snapshot.key) // oUi3NI9SdcbCC6v5EmygDNV4lrg1
            });

firebase – Can anyone Optimize this code in dart. I was making a Search filter for each words

I need to add search filters for firebase So that I can get search result easily and precisely

I was altering the code from hereThis Medium Post

void main() {
  print(setSearchParam("Dr apj abdul Kalam"));
}

setSearchParam(String caseNumber) {
  List<String> caseSearchList = List();
  String temp = "";
  String temp2 = "";
  String temp3 = "";

  if (caseNumber.split(" ").length > 1) {
    String firstWord = caseNumber.split(" ")(0);
    String secondWord = caseNumber.split(" ")(1);
    String thirdWord = caseNumber.split(" ")(2);

    for (int i = 0; i < firstWord.length; i++) {
      temp = temp + firstWord(i);
      caseSearchList.add(temp);
    }
    for (int i = 0; i < secondWord.length; i++) {
      temp2 = temp2 + secondWord(i);
      caseSearchList.add(temp2);
    }
    for (int i = 0; i < thirdWord.length; i++) {
      temp3 = temp3 + thirdWord(i);
      caseSearchList.add(temp3);
    }
  } else {
    for (int i = 0; i < caseNumber.length; i++) {
      temp = temp + caseNumber(i);
      caseSearchList.add(temp);
    }
  }
  return caseSearchList;
}

OutPuts are like List of each word letters = (D, Dr, a, ap, apj, a, ab, abd, abdu, abdul)

I am pushing these lists to firebase so that I can get search results easily…
if there is an alternative for searching in firebase, then pls let me know…

if anyone still didn’t understand my question, pls look at the link I provide above.

firebase – Error saving rules – Line 11: Expected ‘{‘

I am probably missing something but unfortunately I cannot debug =/
I am following the exact steps from the course I’m following, but unfortunately this error won’t go away.
I’ve already re-wrote that like 4 times to see if I had some typo or something
If someone can please help me will be much appreciated.

I am using real-time database, by the way.

{
  "rules": {
    ".read": false,
    ".write": false,
    "users": {
      "$user_id": {
        ".read": "$user_id === auth.uid",
        ".write": "$user_id === auth.uid",
        "expenses": {
          "$expense_id": {
             ".validade": "newData.hasChildren(('description', 'note', 'createdAt', 'amount'))",
             "description": {
               ".validate": "newData.isString() && newData.val().length > 0"
             },
             "note": {
               ".validate": "newData.isString()"
             },
             "createdAt": {
               ".validate": "newData.isNumber()"
             },
             "amount": {
               ".validate": "newData.isNumber()"
             },
                         "$other": {
                ".validate": false
                 }

          }
        },
        "$other": {
          ".validate": false
        }
      }
    }
  }
}

thankz

Connecting WooCommerce with Firebase – Webmasters Stack Exchange

I have developed a tool with Angular for which I would like to offer a free and a paid premium model. Accordingly, a login is possible there. The authentication and the database runs via Firebase.

I present this tool on a separate WordPress website. There you can also find other areas like FAQ, Demos etc. On this site I also listed the prices and offer with WooCommerce the possibility of purchase (subscription model / Paypal).

Now to my question: How do I link both platforms most elegantly? If someone subscribes to the premium model via WooCommerce, the registered user must get premium access via the Angular app. Is there a best practice here?

My approach: after the purchase, I send a token by e-mail, which the user can enter in his profile on the platform. There I check the validity. How would you rate this procedure? And: How do I recognize when someone cancels the Paypal subscription? In this case Premium would have to be revoked.

Thanks in advance for your assessment 😊

How do I retrieve data from multiple nodes in Firebase? Android

I’m trying to retrieve the questions from the questions node from each user as shown in the diagram below. I can’t figure out a way to reach the nodes. How do I retrieve the data from each of the question nodes of the separate users?? someone please help.
enter image description here

firebase – Como puedo obtener los datos en tiempo real con angular y firestore?

Hola muy buen día, quería hacer una consulta,cuando elimino un producto no lo elimina en tiempo real solo cuando actualizo el navegador, lo mismo cuando creo un producto.
tengo en mi servicios este código, osea se que el problema esta en el get pero al cambiarlo por snapshotchanges me arroja un error en .docs , esto es de un curso que estoy haciendo.

Desde ya muchas gracias, nose si darme una solucion o algun tip decomo hacerlo. Ya que no puedo lograr hacerlo.

AQUI COMIENSA EL TYPESCRIPT DE SERVICIO DATA.SERVICE.TS

import { Injectable } from '@angular/core';
import { Producto } from '../interfaces/producto';
import { AngularFirestore } from '@angular/fire/firestore';
import { NgxSpinnerService } from "ngx-spinner";
import Swal from 'sweetalert2';


@Injectable({
  providedIn: 'root'
})
export class DataService {

  private colProduct: string = 'Products';
  private products: Producto() = ();

  constructor(private _firestore: AngularFirestore, private _spinner: NgxSpinnerService) { 

  }

  createProduct(product:Producto): Promise<any>{
   return this._firestore.collection(this.colProduct).add(product);

  }
  showSpinner(): void{
    this._spinner.show();
  }
  hideSpinner(): void{
    this._spinner.hide();
  }
  showAlert(icon:any,title:string,text:string,showConfirmButton: boolean,position:any, timer:number){
    Swal.fire({
      icon: icon,
      title: title,
      text: text,
      showConfirmButton: showConfirmButton,
      position: position,
      timer: timer

    })
  }

  updateProduct(data: any, id: string){

  }

  deleteProduct(id:string): Promise<any>{
   return this._firestore.collection(this.colProduct).doc(id).delete();
  }

  getProducts(): Promise<Producto()>{
    return new Promise(resolve => {

          this._firestore.collection(this.colProduct).get().subscribe((collection) => {
          collection.docs.forEach( d => {
          const data:any = d.data();
          data.id = d.id;
          this.products.push(data);


        });

        resolve(this.products);

      }); 

    });
  }
}

AQUI COMIENZA EL COMPONENTE TYPESCRIPT

    import { Component, OnInit } from '@angular/core';
import { Producto } from '../shared/interfaces/producto';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { DataService } from '../shared/services/data.service';

@Component({
  selector: 'app-catalogo',
  templateUrl: './catalogo.component.html',
  styleUrls: ('./catalogo.component.scss')
})
export class CatalogoComponent implements OnInit {

  public form: FormGroup;

  public data : Producto() = (

);

  constructor(private _data: DataService) { }

  ngOnInit(): void {
    this.form = new FormGroup({
      title: new FormControl('', Validators.required),
      pricing: new FormControl('', Validators.required),
      description: new FormControl('', Validators.required)
    });
    this._data.getProducts().then((data: Producto()) => {
      this.data = data;
    });
  }

  public saveForm(): void {
    this._data.showSpinner();
    const {title,pricing,description} = this.form.value;
    const newProduct: Producto = {
      title: title,
      description: description,
      pricing: pricing,
      image: "https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcT-bDUxZvdsnpfZPesFZMK1pd4fdYd_dNh-oZxTzbyy8siqTx9M&usqp=CAU",
      category: 'calzado',
      creationDate: new Date()

    }
   if(this.form.valid){
    this._data.createProduct(newProduct).then(() => {
      this.form.reset();
      this._data.hideSpinner();
      this._data.showAlert('success','producto creado','su producto ha sido creado',false,'center',3500);

    });

   }else{
    this._data.hideSpinner();
    this._data.showAlert('error','form invalid','validad',false,'center',3500);
   }

  }

   deleteProduct(id:string): void {
     this._data.showSpinner();
     this._data.deleteProduct(id).then(() => {
      this.form.reset();
      this._data.hideSpinner();
      this._data.showAlert('success','producto eliminado','su producto ha sido ELIMINADO',false,'center',3500);

    });
   }
}

**desde ya muchas gracias!

reactjs – ¿Como mostrar una lista de datos obtenidos de Firebase en React?

Estoy realizando un ejercicio de aplicacion web, un CRUD en React utilizando Hook y Firebase. Logre realizar el registro y mostrar su contenido en la consola. Pero necesito mostrar una lista de su contenido. ¿Como puedo realizar una lista con un map(), que me muestre el valor de “Codigo” y “Formula”?. He probado diferentes formas y no he tenido exito.

Imagen de la DB en Firebase

const firebase= useFirebaseApp();

function mostrarnewformula(){
const database = firebase.database();
var ref = database.ref(`/formula`);
ref.once("value").then(function(snapshot) {
   snapshot.forEach(function(childSnapshot) {
     var key = childSnapshot.key;
     var childData = childSnapshot.val();
     console.log(key);
     console.log(childData)
   }); 
 
  });  return (  <div><p>Lista:  </p><li></li></div>)
}

return(
<Fragment>
<div className="container">
    MOSTRAR:{mostrarnewformula()}
</div>
</Fragment>
)

}