skip to Main Content

passing an array of objects in postgresql using node

var query = `select * from map_balances where balance_userid = $1 AND balance_vendorid = $2 AND balance_amount >= $3` var values = [accesstoken,token,arr.map(e=>e.vid),arr.map(e=>e.amt)]; client.query(query,{arr:values},async(err,projectdata)=>{ if (err) { res.json({success:false,message:err.message,responsecode:-1}); } else { res.json({success:true,message:projectdata.rowCount,responsecode:200}); } }); here arr=[{"vid": 636,"amt": "21","add": "123123"},{"vid": 636,"amt":…

VIEW QUESTION

Mongodb – const err = new MongooseError(message); MongooseError: Operation `fruits.insertOne()` buffering timed out after 10000ms

const mongoose = require("mongoose"); mongoose.set('strictQuery', false); mongoose.connect("mongodb://localhost:27017/fruitsDB", {useNewUrlParser: true}); const fruitSchema = new mongoose.Schema ({ name:String, rating: Number, review: String }); const Fruit = mongoose.model("Fruit", fruitSchema); const fruit = new Fruit ({ name: "Apple", rating: 7, review: "Pretty good" });…

VIEW QUESTION
Back To Top
Search