BigChainDb: testnet.bigchaindb.com with MongoDb?

421 views Asked by At

So why I am following this example:

https://github.com/manolodewiner/query-mongodb-bigchaindb/blob/master/queryMongo.js

but I am using a testnet server provided by bigChainDb, so I am doing this:

const MongoClient = require('mongodb').MongoClient;


const urlMongo = 'mongodb://localhost:27017'

const dbName = 'bigchain'




let conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', { 
    app_id: 'yyyyyy',
    app_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
})

const alice = new driver.Ed25519Keypair();
const bob = new driver.Ed25519Keypair();

const assetdata = {
    'invoice': {
            'invoiceNo': '811',
            'issuedBy': 'supplier1',
    }

}

Which apparently is wrong because according to documentation here:

How to Connect to MongoDB Before you can query a MongoDB database, you must connect to it, and to do that, you need to know its hostname and port.

If you’re running a BigchainDB node on your local machine (e.g. for dev and test), then the hostname should be localhost and the port should be 27017, unless you did something to change those values. If you’re running a BigchainDB node on a remote machine and you can SSH to that machine, then the same is true.

If you’re running a BigchainDB node on a remote machine and you configured its MongoDB to use auth and to be publicly-accessible (to people with authorization), then you can probably figure out its hostname and port.

https://docs.bigchaindb.com/en/latest/query.html

In the example code, manolodewiner is 'pairing' his local bigchaindb with the local mongodb, which is the default setup, right?

But in my current code, I am obviously pointing to my local mongodb but the bigchain is remote, on the bigchain's test network, but this is not working- nothing is being written on my local mongodb and no mongo query is working, what should I do in order to "pair" the remote test.bigchaindb with my local mongodb?

2

There are 2 answers

1
Troy McConaghy On BEST ANSWER

The current BigchainDB Testnet (at test.bigchaindb.com) doesn't allow external users to connect directly to the MongoDB instances in its nodes. Nor can you start up a local node and add it to the BigchainDB Testnet. It's a "permissioned network": existing network nodes must explicitly add your node to the network.

0
Franco Ugarte On

So I'm not getting what the point is. I want to do proof-of-concept, but if I can't verify that the data persists "on the network", even though my server "crashes", then I'm not checking for anything more than a simple traditional mongoDB query.