bigchaindb / bigchaindb-driver

Official Python driver for BigchainDB
https://www.bigchaindb.com
Apache License 2.0
105 stars 104 forks source link

Problem: no easy ORM for CRUD/CRAB #455

Open diminator opened 6 years ago

diminator commented 6 years ago

Description

Simple operations like

create and retrieve are quite easy to use, but update/transfer is very convoluted. From the docs:

txid = fulfilled_creation_tx['id']

asset_id = txid

transfer_asset = {
    'id': asset_id
}

output_index = 0
output = fulfilled_creation_tx['outputs'][output_index]

transfer_input = {
    'fulfillment': output['condition']['details'],
    'fulfills': {
        'output_index': output_index,
        'transaction_id': fulfilled_creation_tx['id']
    },
    'owners_before': output['public_keys']
}

prepared_transfer_tx = bdb.transactions.prepare(
    operation='TRANSFER',
    asset=transfer_asset,
    inputs=transfer_input,
    recipients=bob.public_key,
)

fulfilled_transfer_tx = bdb.transactions.fulfill(
    prepared_transfer_tx,
    private_keys=alice.private_key,
)

sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)

There are many moving parts where things can go wrong. I would expect a simple ORM syntax will drive adoption.

The js-driver-orm is a good starting point for this...

vrde commented 6 years ago

@diminator thanks for opening this issue. I definitely agree with you, we need to make this operations "primitives" of the system. I think it's time to write a BEP.

diminator commented 6 years ago

I think it's time to write a BEP.

yes, it's time :)