2018-01-24 09:35:09 +08:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2019-03-05 03:03:12 +08:00
|
|
|
import { Model } from '../../src/flux/models/model';
|
|
|
|
import { Category } from '../../src/flux/models/category';
|
|
|
|
import Attributes from '../../src/flux/attributes';
|
2018-01-24 09:35:09 +08:00
|
|
|
|
|
|
|
class TestModel extends Model {
|
|
|
|
static attributes = {
|
|
|
|
id: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'id',
|
|
|
|
}),
|
|
|
|
|
|
|
|
clientId: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'clientId',
|
|
|
|
jsonKey: 'client_id',
|
|
|
|
}),
|
|
|
|
|
|
|
|
serverId: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'serverId',
|
|
|
|
jsonKey: 'server_id',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
TestModel.configureBasic = () =>
|
|
|
|
(TestModel.attributes = {
|
|
|
|
id: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'id',
|
|
|
|
}),
|
|
|
|
clientId: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'clientId',
|
|
|
|
jsonKey: 'client_id',
|
|
|
|
}),
|
|
|
|
serverId: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'serverId',
|
|
|
|
jsonKey: 'server_id',
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
TestModel.configureWithAllAttributes = () =>
|
|
|
|
(TestModel.attributes = {
|
|
|
|
datetime: Attributes.DateTime({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'datetime',
|
|
|
|
}),
|
|
|
|
string: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'string',
|
|
|
|
jsonKey: 'string-json-key',
|
|
|
|
}),
|
|
|
|
boolean: Attributes.Boolean({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'boolean',
|
|
|
|
}),
|
|
|
|
number: Attributes.Number({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'number',
|
|
|
|
}),
|
|
|
|
other: Attributes.String({
|
|
|
|
modelKey: 'other',
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
TestModel.configureWithCollectionAttribute = () =>
|
|
|
|
(TestModel.attributes = {
|
|
|
|
id: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'id',
|
|
|
|
}),
|
|
|
|
clientId: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'clientId',
|
|
|
|
jsonKey: 'client_id',
|
|
|
|
}),
|
|
|
|
serverId: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'serverId',
|
|
|
|
jsonKey: 'server_id',
|
|
|
|
}),
|
|
|
|
other: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'other',
|
|
|
|
}),
|
|
|
|
categories: Attributes.Collection({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'categories',
|
|
|
|
itemClass: Category,
|
|
|
|
joinOnField: 'id',
|
|
|
|
joinQueryableBy: ['other'],
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
TestModel.configureWithJoinedDataAttribute = function() {
|
|
|
|
TestModel.attributes = {
|
|
|
|
id: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'id',
|
|
|
|
}),
|
|
|
|
clientId: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'clientId',
|
|
|
|
jsonKey: 'client_id',
|
|
|
|
}),
|
|
|
|
serverId: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'serverId',
|
|
|
|
jsonKey: 'server_id',
|
|
|
|
}),
|
|
|
|
body: Attributes.JoinedData({
|
|
|
|
modelTable: 'TestModelBody',
|
|
|
|
modelKey: 'body',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
TestModel.attributes = {
|
|
|
|
id: Attributes.String({
|
|
|
|
queryable: true,
|
|
|
|
modelKey: 'id',
|
|
|
|
}),
|
|
|
|
clientId: Attributes.String({
|
|
|
|
modelKey: 'clientId',
|
|
|
|
jsonKey: 'client_id',
|
|
|
|
}),
|
|
|
|
serverId: Attributes.String({
|
|
|
|
modelKey: 'serverId',
|
|
|
|
jsonKey: 'server_id',
|
|
|
|
}),
|
|
|
|
body: Attributes.JoinedData({
|
|
|
|
modelTable: 'TestModelBody',
|
|
|
|
modelKey: 'body',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-03-05 03:03:12 +08:00
|
|
|
export default TestModel;
|