1.18.0 • Published 5 years ago

@cdutils/supermodel v1.18.0

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
5 years ago

SuperModel

It's simple...

1. Connect to the database

const connection: DatabaseConnection = new DatabaseConnection({
    hostname: '...',
    user: '...',
    password: '...',
    database: '...'
});

2. Define a model

@ModelClass('account', connection)
class Account extends Model {

    public async getUsername(): Promise<string> {
        return this.get<string>('username');
    }

    public setUsername(username: string): void {
        return this.set('username', username);
    }

}

3. Insert an item to the table

const account: Account = new Account({
    username: 'johndoe'
});
await account.save();

4. Fetch an item from the table

const account: Account = await Account
    .findOne()
    .where('username').isLike('johndoe')
    .exec();
console.log('We found: ' + await account.getUsername());

That's all there is to it.

1.18.0

5 years ago

1.17.0

5 years ago

1.16.0

5 years ago

1.15.0

5 years ago

1.13.0

5 years ago

1.12.0

5 years ago

1.10.0

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago