finish database implementation
This commit is contained in:
24
app/models/api/db/ColumnDef.model.js
Normal file
24
app/models/api/db/ColumnDef.model.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const Model = require('flitter-orm/src/model/Model')
|
||||
const uuid = require('uuid/v4')
|
||||
|
||||
/*
|
||||
* ColumnDef Model
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class ColumnDef extends Model {
|
||||
static get schema() {
|
||||
// Return a flitter-orm schema here.
|
||||
return {
|
||||
headerName: String,
|
||||
field: String,
|
||||
DatabaseId: String,
|
||||
UUID: { type: String, default: () => uuid() },
|
||||
Type: { type: String, default: 'text' }, // text, number for now
|
||||
}
|
||||
}
|
||||
|
||||
// Static and instance methods can go here
|
||||
}
|
||||
|
||||
module.exports = exports = ColumnDef
|
||||
22
app/models/api/db/DBEntry.model.js
Normal file
22
app/models/api/db/DBEntry.model.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const Model = require('flitter-orm/src/model/Model')
|
||||
const uuid = require('uuid/v4')
|
||||
|
||||
/*
|
||||
* DBEntry Model
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class DBEntry extends Model {
|
||||
static get schema() {
|
||||
// Return a flitter-orm schema here.
|
||||
return {
|
||||
DatabaseId: String,
|
||||
RowData: Object,
|
||||
UUID: { type: String, default: () => uuid() },
|
||||
}
|
||||
}
|
||||
|
||||
// Static and instance methods can go here
|
||||
}
|
||||
|
||||
module.exports = exports = DBEntry
|
||||
28
app/models/api/db/Database.model.js
Normal file
28
app/models/api/db/Database.model.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const Model = require('flitter-orm/src/model/Model')
|
||||
const uuid = require('uuid/v4')
|
||||
|
||||
/*
|
||||
* Database Model
|
||||
* -------------------------------------------------------------
|
||||
* Put some description here!
|
||||
*/
|
||||
class Database extends Model {
|
||||
static get schema() {
|
||||
// Return a flitter-orm schema here.
|
||||
return {
|
||||
Name: String,
|
||||
NodeId: String,
|
||||
PageId: String,
|
||||
ColumnIds: [String],
|
||||
UUID: { type: String, default: () => uuid() },
|
||||
}
|
||||
}
|
||||
|
||||
accessible_by(user, mode = 'view') {
|
||||
return user.can(`database:${this.UUID}:${mode}`)
|
||||
}
|
||||
|
||||
// Static and instance methods can go here
|
||||
}
|
||||
|
||||
module.exports = exports = Database
|
||||
Reference in New Issue
Block a user