小编Div*_*lla的帖子

获取满足查询条件的文档ID

我想获得满足云端防火墙中给定查询的文档ID.我的数据库的架构就像这个deyaPayusers/AuthId /用户详细信息PhoneNo:/ Wallet/Transaction我知道PhoneNo,那么有没有办法获得相应的AuthId.我实现了我的想法,如下所述,我遇到了这个错误

参数"documentPath"不是有效的ResourcePath.路径必须是非空字符串.

const functions = require('firebase-functions');
const Firestore = require('@google-cloud/firestore');
const firestore = new Firestore();
const admin = require('firebase-admin');
    exports.transactionDetails = functions.firestore
        .document('deyaPayusers/{authid}/Transaction/{authid1}')
            .onWrite(event=>{
            const db1 = admin.firestore();
            const MAuth = event.params.authid
            const transid = event.params.authid1
            var payeeDocId
            var newValue = event.data.data();
            var payee = newValue.Payee;//Phone number of money receiver
            var amt = newValue.Amount;//Amount willing to pay to payee(money receiver)
            var usersRef = db1.collection('deyaPayusers').doc(MAuth);//Refers to payer doc
            var payer = usersRef.PhoneNo;//Gets Phonenumber attribute of payer
            const walletRefPayer = …
Run Code Online (Sandbox Code Playgroud)

node.js google-cloud-functions google-cloud-firestore

6
推荐指数
1
解决办法
3278
查看次数

如何将数据从Web存储到Firestore

我为用户创建了一个注册页面,当用户单击注册按钮时,我想将输入的注册详细信息存储到FireStore。它没有显示任何错误,但是数据没有存储在Firestore中。我的JavaScript文件是:

var config = {
    apiKey: "AIzaSyAJsAstiMsrB2QGJyoqiTELw0vsWFVVahw",
    authDomain: "websignin-79fec.firebaseapp.com",
    databaseURL: "https://websignin-79fec.firebaseio.com",
    projectId: "websignin-79fec",
    storageBucket: "",
    messagingSenderId: "480214472501"
  };
   firebase.initializeApp(config);
   var db=firebase.firestore();
  const inputTextfield = document.querySelector("#firstname").value;// it takes the values from signup page.
  const lastname = document.querySelector("#lastname").value;
  const email = document.querySelector("#email").value;
  const phonenumber = document.querySelector("#phone").value;
  //const savebutton=document.querySelector("#submit");
  console.log(inputTextfield);
  const save=document.querySelector("#submit");
  save.addEventListener("click",function() {
      db.collection("deyaPayusers").add({
                Name:inputTextfield,
                Email:email,
                PhoneNo:phonenumber,
                laseName:lastname,


      }).then(function() {

      console.log("Document successfully wriiten!");

})
.catch(function(error) {
    // The document probably doesn't exist.
    console.error("Error writing document: ", error);
});
}); 
Run Code Online (Sandbox Code Playgroud)

我的注册页面是:

<!doctype html> …
Run Code Online (Sandbox Code Playgroud)

html javascript google-cloud-firestore

5
推荐指数
1
解决办法
992
查看次数

什么是使用Web3.providers.HttpProvider("")

我想使用web3js与智能合约进行交互.每个示例都将从以下开始

var Web3 = require('web3');
var web3 = new Web3('http://localhost:8545');
// or
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
Run Code Online (Sandbox Code Playgroud)

我不明白使用Web3.providers.HttpProvider('Address').我的猜测:因此,在建立专用网络时,每个节点都应该提供一个不同的rpcport来识别它,因此它连接到网络.我错了吗?例如,上面的代码用于网站的前端,以便连接前端并在以太坊专用网络中部署合同.因此,前端代码必须是通用的,这意味着它不应该在其代码中添加特定的以太坊节点地址.那么什么是使用Web3.providers.HttpProvider('地址')?

ethereum web3js go-ethereum

5
推荐指数
1
解决办法
3795
查看次数

将新集合添加到 firestore 中现有文档的云功能

我想将新集合添加到 firestore 中已存在的文档中。这可能吗?以下是执行此操作的代码,我使用云函数来执行此操作。每当在 firestore 中创建文档时,就必须触发以下云函数

const functions = require('firebase-functions');
const Firestore = require('@google-cloud/firestore');
const firestore = new Firestore();
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.myWallet = functions.firestore
    .document('Samyata/{authid}')
        .onCreate(event =>{
        const ID = event.params.authid
        const db = admin.firestore();
        var data = {
        Bitcoins : '0',
        Ether : '0',
        deyaCoins : '0'
        };
        var docRef = db.collection('Samyata').doc(ID);
        var updateDoc = docRef.update({
        db.collection('Samyata').doc(ID).collection('Wallet').doc(ID).set(data);});
        //var updateRef = docRef.update();
        });//end of onCreate() 
Run Code Online (Sandbox Code Playgroud)

node.js google-cloud-functions google-cloud-firestore

2
推荐指数
1
解决办法
2961
查看次数