zkDatabase
zkDatabase copied to clipboard
Handle data schema and store o1js Struct in MongoDB
We may need to define a schema collection in each data that define the structure of o1js Struct
to allow us to serialize/deserialize an o1js Struct
from mongo Document
. This is necessary for Merkle tree implementation.
Expectation:
{
collection: string,
schema: any,
createdAt: Date,
updatedAt: Date
}
collection
is the collection name to store actual data and of course data need to satisfy the type validation of the schema.
E.g:
const User = Struct({age: Uint32, user: PublicKey});
Apparently age
can't be a string, the schema was use to guarantee the consistent from both side.