fairDataSociety / fdp-contracts

Fair Data Protocol smart contracts and its utilities
4 stars 1 forks source link

Proposal: Swarm DB - ORM tooling #87

Open molekilla opened 1 year ago

molekilla commented 1 year ago

Swarm DB - ORM Object Relational Mapper

Swarm DB ORM Object Relational Mapper

Summary

A well design database is able to work with an ORM Object Relational Mapper, in this case we take ideas from existing tooling like Typechain, AbiType, Solido, and Web 2.0 tooling like Mongoose

Guide-level explanation

Beeson type mapping

We can create a type mapper to build Code-first Typescript classes using annotations.

class MyBeesonClass {
  @simpleType({
    name: 'qty' // optional,
    type: 'uint'
  })
  public quantity: number;

 @containerType({
    type: 'SoC'
  })
  public inventoryRefs: [];

  @contractMappingTo({ address, method, name, options })
  public transferMethod: (sendTo: string, wei: BigNumber) => Promise<any>;

  @query(` ... JEXL query...`)
  public listExistingInventoryByLocation() // eg Spring Boot like
}

Copyright

Copyright and related rights waived via CC0.

Author

@molekilla (Rogelio Morrell)