``I workk with stellar network , I create an account with stellar laboratry and node.js,in the begin I save the data in Json file and everything works perfectly but now I want to save it into the database, the signup function work correctly but when I try to check the balance account I am bloked and I have Errors So my question : I want to use the publickey from the user_account in the database and check the balance using Stellar Horizen
How can I do it ?``
This is the data for the user when he sign up
**SignUp function **
const userModel= require('../models/user.model')
const { errorsSignUp,errorsSignIn } = require('../utils/errors')
const stellar = require("stellar-sdk");
module.exports.signUp= async(req,res)={
const {pseudo,email,password}= req.body
try{
const pair = stellar.Keypair.random();
const userData= await userModel.create(
{
pseudo,
email,
password,
publicKey: pair.publicKey(),
secret:pair.secret(),
})
// await userData.save()
res.send(userData)
res.status(201).json({userData:userData._id})`
}
catch(err){
const errors= errorsSignUp(err)
res.status(200).send({errors})
}
}
Check balance function
const stellar= require('stellar-sdk')
const accounts= require("./accounts")
const util = require("util")
//const userModel = require('../models/user.model')
// function without mongodb
// saving data in file.json
var server= new stellar.Server("https://horizon-testnet.stellar.org")
const checkAccount= async accounts={
const AccountsBalance= await Promise.all(
accounts.map(async account= await server.loadAccount(account.publicKey)))
return AccountsBalance.map(({id,balances})=({
id,
balances,
}))
}
checkAccount(accounts)
.then(account=
console.log(util.inspect(account,false, null))
)
.catch(error={
console.log(error)
})