Firebase: Copying data from firebase database of one user to another users database

When I am running npm install firebase-tools inside my app folder, i am getting errors

C:\Users\hp\cloudfunctions>npm install -g firebase-tools
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\requires-port\-\requires-port-1.0.0.tgz.4119137865' -> 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\requires-port\-\requires-port-1.0.0.tgz'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10

npm ERR! tarball.destroy is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\revalidator\-\revalidator-0.1.8.tgz.3233374140' -> 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\revalidator\-\revalidator-0.1.8.tgz'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10

npm ERR! tarball.destroy is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\i\-\i-0.3.5.tgz.3955077155' -> 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\i\-\i-0.3.5.tgz'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10

npm ERR! tarball.destroy is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\ncp\-\ncp-1.0.1.tgz.3106952031' -> 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\ncp\-\ncp-1.0.1.tgz'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10

npm ERR! tarball.destroy is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\async\-\async-0.9.2.tgz.641228602' -> 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\async\-\async-0.9.2.tgz'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10

npm ERR! tarball.destroy is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\ncp\-\ncp-1.0.1.tgz.9776215' -> 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\ncp\-\ncp-1.0.1.tgz'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10

npm ERR! tarball.destroy is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm WARN retry will retry, error on last attempt: Error: EBUSY: resource busy or locked, rename 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\async\-\async-0.9.2.tgz.3294582512' -> 'C:\Users\hp\AppData\Local\Temp\npm-7400-f018535c\registry.npmjs.org\async\-\async-0.9.2.tgz'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10

npm ERR! tarball.destroy is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

Please help me with this issue…

the above issue is resolved,but when after deploying firebase functions ,on running the project ,I am getting error,

I got this error resolved but now another issue…

You’re trying to use FormGroup but you are missing either importing it or injecting the provider inside the constructor, without checking out your code is hard to tell.

create.ts file

import { Component } from '@angular/core';
import { IonicPage, NavController, Loading, LoadingController,NavParams } from 'ionic-angular';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AngularFireAuth } from 'angularfire2/auth';


@Component({
  selector: 'page-create',
  templateUrl: 'create.html',
})
export class CreatePage {

  constructor(public navCtrl: NavController,  public signupForm:FormGroup,
public loading:Loading,public navParams: NavParams,public loadCtrl: LoadingController, 
public formBuilder: FormBuilder, public afAuth: AngularFireAuth) {


   this.signupForm = formBuilder.group({
    email: ['', Validators.required],
    password: ['', Validators.compose([Validators.minLength(6), Validators.required])]
  });

}
signupUser(){
  if (!this.signupForm.valid){
    console.log(this.signupForm.value);
  } else {
    this.afAuth.auth.createUserWithEmailAndPassword(this.signupForm.value.email, this.signupForm.value.password)
    .then(() => {
      this.loading.dismiss().then( () => {
        this.navCtrl.setRoot('HomePage');
      });
    }, (error) => {
      this.loading.dismiss().then( () => {
        console.error(error);
      });
    });
    this.loading = this.loadCtrl.create();
    this.loading.present();
  }
}


  ionViewDidLoad() {
    
  }

}

app.module.ts


import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import{SignupPage}from'../pages/signup/signup';
import{CreatePage}from'../pages/create/create';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { AngularFireModule } from 'angularfire2';
import { AngularFireAuthModule } from 'angularfire2/auth';

//import{FormsModule} from'@angular/forms';
export const firebaseCredential = {
     apiKey: "AIzaSyCCzPsozYLjOhk_HmgfhYZBW6DD4t2hUQg",
    authDomain: "fir-chatapp-15363.firebaseapp.com",
    databaseURL: "https://fir-chatapp-15363.firebaseio.com",
    projectId: "fir-chatapp-15363",
    storageBucket: "fir-chatapp-15363.appspot.com",
    messagingSenderId: "89770370712"
  };

@NgModule({
  declarations: [
    MyApp,
    HomePage,
    SignupPage,
    CreatePage

  ],
  
  imports: [

    BrowserModule,
  ReactiveFormsModule,
    IonicModule.forRoot(MyApp),
    AngularFireModule.initializeApp(firebaseCredential),
    AngularFireAuthModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    SignupPage,
    CreatePage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

create.html

<ion-header>
  <ion-navbar color="primary">
    <ion-title>
      Create an Account
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <form [formGroup]="signupForm" (submit)="signupUser()" novalidate>

    <ion-item>
      <ion-label stacked>Email</ion-label>
      <ion-input formControlName="email" type="email" placeholder="Your email address" 
        [class.invalid]="!signupForm.controls.email.valid && signupForm.controls.email.dirty">
      </ion-input>
    </ion-item>
    <ion-item class="error-message" 
      *ngIf="!signupForm.controls.email.valid  && signupForm.controls.email.dirty">
      <p>Please enter a valid email.</p>
    </ion-item>

    <ion-item>
      <ion-label stacked>Password</ion-label>
      <ion-input formControlName="password" type="password" placeholder="Your password" 
        [class.invalid]="!signupForm.controls.password.valid && signupForm.controls.password.dirty">
      </ion-input>
    </ion-item>
    <ion-item class="error-message" 
      *ngIf="!signupForm.controls.password.valid  && signupForm.controls.password.dirty">
      <p>Your password needs more than 6 characters.</p>
    </ion-item>

    <button ion-button block type="submit" [disabled]="!signupForm.valid">
      Create an Account
    </button>
  </form>
</ion-content>

The issue is resolved…thanks,but how to implement multiple sharing of firebase database.

1 Like

In this way I am able to share one record ,but now I want to enable multiple selections,like If I have 5 books ,I am able to share now one book at a time…but how to select multiple books at a time and push it to other user in the same way,as we are sharing a single file at a time…

Firebase uses WebSockets and MongoDB for real-time database management. They are powerful and offer total control across the database - Contus Fly Chat kit

1 Like

Thanks for the Information,
Appreciate it.
I used firebase cloud functions to solve it.