Ookma-Kyi
06/14/2023, 2:51 AMcomponent {
function up( schema, query ){
schema.create( "characters", function(table) {
table.unsignedInteger( "userid" ).references( "id" ).onTable( "users" ).onDelete( "cascade" );
...
} );
}
function down( schema, query ){
schema.drop( "characters" );
}
}
elpete
06/14/2023, 4:45 AMproperty type
?elpete
06/14/2023, 4:45 AMusers.id
?elpete
06/14/2023, 4:45 AMusers
table and it must match your userid
column on the table with the foreign key.Ookma-Kyi
06/14/2023, 5:22 AMelpete
06/14/2023, 5:56 AMRyan Albrecht
06/14/2023, 12:15 PMOokma-Kyi
06/14/2023, 5:50 PMcomponent extends="quick.models.BaseEntity" accessors="true" {
property name="id" type="number";
// foreign key to user.id
property name="userid" type="nuber";
property name="deleted" type="boolean";
property name="active" type="boolean";
property name="name" type="string";
property name="xp" type="number";
// foreign key to belt.id
property name="belt" type="number";
property name="wins" type="number";
property name="loses" type="number";
property name="draws" type="number";
public Character function retrieveCharacterByName( required string name ){
return newEntity().where( "name", arguments.name ).firstOrFail();
}
public Character function retrieveCharacterById( required numeric id ){
return newEntity().findOrFail( arguments.id );
}
public struct function getMemento(){
return { "name" : variables.getName() };
}
}
@Ryan Albrecht Yes I am using quick ORMRyan Albrecht
06/14/2023, 6:04 PMRyan Albrecht
06/14/2023, 6:05 PMcomponent
extends="BaseEntity"
accessors="true"
table="currency_pair"
{
property name="id";
property name="code";
property name="baseCurrencyId";
property name="quoteCurrencyId";
this.constraints.append({
code: { required: true },
baseCurrencyId: { required: true },
quoteCurrencyId: { required: true },
});
function baseCurrency() {
return belongsTo( "Currency", 'baseCurrencyId');
}
function quoteCurrency() {
return belongsTo( "Currency", 'quoteCurrencyId' );
}
}
Ryan Albrecht
06/14/2023, 6:07 PMbaseCurrencyId
and quoteCurrencyId
which are both many to one relationshipsRyan Albrecht
06/14/2023, 6:07 PMelpete
06/14/2023, 7:11 PMsqltype
, you can add a sqltype
attribute to your property.
https://quick.ortusbooks.com/guide/getting-started/defining-an-entity#sql-typeelpete
06/14/2023, 7:12 PMOokma-Kyi
06/14/2023, 7:36 PMproperty name="code";
this.constraints.append({
code: { required: true },
});
}
not the same as:
property name="code" required="true";
Ryan Albrecht
06/14/2023, 7:38 PMRyan Albrecht
06/14/2023, 7:38 PMRyan Albrecht
06/14/2023, 7:38 PM