Tachyon
v0.0.1
Published
TachyonDB schemaless, asynchronous data modeling library. *Disclaimer: not production tested, or spec complete!*
Downloads
2
Readme
tachyon
TachyonDB schemaless, asynchronous data modeling library. Disclaimer: not production tested, or spec complete!
introduction
TachyonDB provides a schemaless interface for building and manipulating object models on top of relational databases.
interface
defining a model
const UserEntity = new EntityType('User', {
canonicalEmail: { type: Types.string, index: true },
firstName: { type: Types.string },
lastName: { type: Types.string },
genderPreference: { type: Types.number },
createdAt: { type: Types.dateTime, index: true}
})
inserting a model
const newUser = UserEntity
user.setProperty(
'canonicalEmail',
'[email protected]'
)
insertEntity((newUser)
.then((user) => {
console.log(`user ${user.getProperty('canonicalEmail')} added`)
})
retrieving a model
getEntityByKeyValue(
UserEntity.type,
UserEntity.schema.canonicalEmail.type,
'canonicalEmail',
'[email protected]'
)
.then((user) => {
if (user) {
console.log(`user ${user.getProperty('canonicalEmail')} retrieved`)
}
})