This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (err is HttpException) { | |
val code = err.response().code() | |
Log.d("HttpException", "code $code") | |
val body = retrofit.converter<ErrorResponse>(err) | |
Log.d("HttpException", "body ${body.message}") | |
} | |
data class ErrorResponse(val message: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('test', function () { | |
$arr = []; | |
for ($i=0; $i<1000; $i++) { | |
$arr[] = $i+1; | |
} | |
return response(paginate($arr)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// callback style | |
Users.all((err, users) => { | |
users.posts().fetch((err, bicycles) => { | |
res.send({ users, bicycles }) | |
}) | |
}) | |
// promise style | |
let users = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Database | Npm driver | |
---|---|---|
PostgreSQL | npm i pg | |
MySQL | npm i mysql or npm i mysql2 | |
MariaDB | npm i mariasql | |
SQLite3 | npm i sqlite3 | |
Oracle | npm i oracledb or npm i strong-oracle | |
MSSQL | npm i mssql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const Schema = use('Schema') | |
class UserSchema extends Schema { | |
up () { | |
this.create('users', table => { | |
table.increments() | |
table.string('username', 80).notNullable().unique() | |
table.string('email', 254).notNullable().unique() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const Schema = use('Schema') | |
class NewsSchema extends Schema { | |
up () { | |
this.create('news', (table) => { | |
table.increments() | |
table.string('title', 100) | |
table.text('content') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const Factory = use('Factory') | |
const Hash = use('Hash') | |
Factory.blueprint('App/Models/User', async (faker) => { | |
return { | |
username: faker.username(), | |
email: faker.email({ domain: "example.com"}), | |
password: await Hash.make(faker.password()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
/* | |
|-------------------------------------------------------------------------- | |
| UserSeeder | |
|-------------------------------------------------------------------------- | |
| | |
| Make use of the Factory instance to seed database with dummy data or | |
| make use of Lucid models directly. | |
| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fungsi select | |
const users = await Database.from('users').where('id', 1)await Database.select('*').from('users') | |
// fungsi select kolom tertentu | |
const users = await Database.from('users').where('id', 1)await Database.select('id', 'username').from('users') | |
// fungsi where clause | |
const users = await Database.from('users').where('id', 1)await Database.from('users').where('id', 1) | |
// fungsi join tabel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const Model = use('Model') | |
class News extends Model { | |
} | |
module.exports = News |
OlderNewer