Skip to content

4.0.0-beta.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@QSmally QSmally released this 29 Aug 09:18
· 887 commits to v4 since this release

This release drafts the first version of QDB4 in beta!

There were a few little fixes in this release regarding documentation, internal changes and the FetchAll Executor.

This release also implements one large addition: Schemas.

  • Create a database Schema Model with new QDB.Schema(Id: String, Model: Object|Array, Serialiser?: Function) -> Schema.
  • Access Schemas by storing the instance in a variable, or using QDB.Model(Id: String) -> Schema to retrieve it.
  • Bind a Model to a Connection using the Schema attribute in the Connection options: new QDB.Connection(Path: Pathlike, {Schema: QDB.Model(Id: String)}) -> Connection|PartialConnection.
  • When you start your application, include the -m or --migrate command line attribute to indicate the Schema Model has changed and it will convert all the entries in the database with the new model on initialisation.

With Schemas, you can also implement Serialisers. There wasn't much work done, as it's just a function variable, but it allows the possibility to create complex DataModels on request. Say you have a public method that converts a User entry into some API-driven context:

function FetchUser(Id) {
  const User = MyDB.Fetch(Id);
  if (!User) return undefined;
  return MyDB.Model("User").Serialiser(User);
}