I am learning IPFS and trying to save IPFS
file info in MongoDB. After uploading, I get one hash value
ex: {fileHash: CID(QmbCaWPi9tSqcnykvBUMaH2M1d5PiVPLEfPwhJksSSeMak)}
And in MongoDB, I see something like this:
"fileHash": {
"code": 112,
"version": 0,
"multihash": {
"code": 18,
"size": 32,
"digest": "vxaISoMOXTpFy9rwnYilyk7pa6TlhkFDCZgcjGhXfm0=",
"bytes": "EiC/FohKgw5dOkXL2vCdiKXKTulrpOWGQUMJmByMaFd+bQ=="
},
"bytes": "EiC/FohKgw5dOkXL2vCdiKXKTulrpOWGQUMJmByMaFd+bQ=="
}
Now I want to update this document based on hash
value but don't understand what value I compare in match.
db.collection("test").update(filter, set);
I was trying like this:
db.collection("test").update({fileHash:"CID(QmbCaWPi9tSqcnykvBUMaH2M1d5PiVPLEfPwhJksSSeMak)"}, set);
But it doesn't work
I think
CID()
is like a function.When you use
CID("QmbCaWPi9tSqcnykvBUMaH2M1d5PiVPLEfPwhJksSSeMak")
, it come up with a JSON.So you should try something like