Formatting.
This commit is contained in:
parent
564cdd8102
commit
11c52f26ad
|
@ -29,7 +29,7 @@
|
|||
integration = {
|
||||
type: integrationType,
|
||||
plus: selected.plus,
|
||||
...schema
|
||||
...schema,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
name,
|
||||
source: type,
|
||||
config,
|
||||
plus
|
||||
plus,
|
||||
})
|
||||
notifications.success(`Datasource ${name} created successfully.`)
|
||||
analytics.captureEvent("Datasource Created", { name, type })
|
||||
|
|
|
@ -69,7 +69,7 @@ export const deleteRow = async ({ tableId, rowId, revId }) => {
|
|||
body: {
|
||||
_id: rowId,
|
||||
_rev: revId,
|
||||
}
|
||||
},
|
||||
})
|
||||
res.error
|
||||
? notificationStore.danger("An error has occurred")
|
||||
|
|
|
@ -10,11 +10,16 @@ async function buildIDFilter(id) {
|
|||
return {
|
||||
equal: {
|
||||
id: id,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRequest(appId, operation, tableId, { id, row, filters, sort, paginate }) {
|
||||
async function handleRequest(
|
||||
appId,
|
||||
operation,
|
||||
tableId,
|
||||
{ id, row, filters, sort, paginate }
|
||||
) {
|
||||
let [datasourceId, tableName] = tableId.split("/")
|
||||
let idFilter = buildIDFilter(id)
|
||||
let json = {
|
||||
|
@ -34,49 +39,56 @@ async function handleRequest(appId, operation, tableId, { id, row, filters, sort
|
|||
return makeExternalQuery(appId, json)
|
||||
}
|
||||
|
||||
exports.patch = async (ctx) => {
|
||||
exports.patch = async ctx => {
|
||||
const appId = ctx.appId
|
||||
const inputs = ctx.request.body
|
||||
const tableId = ctx.params.tableId
|
||||
const id = inputs._id
|
||||
// don't save the ID to db
|
||||
delete inputs._id
|
||||
ctx.body = await handleRequest(appId, DataSourceOperation.UPDATE, tableId, { id, row: inputs })
|
||||
ctx.body = await handleRequest(appId, DataSourceOperation.UPDATE, tableId, {
|
||||
id,
|
||||
row: inputs,
|
||||
})
|
||||
}
|
||||
|
||||
exports.save = async (ctx) => {
|
||||
exports.save = async ctx => {
|
||||
const appId = ctx.appId
|
||||
const inputs = ctx.request.body
|
||||
if (inputs._id) {
|
||||
return exports.patch(ctx)
|
||||
}
|
||||
const tableId = ctx.params.tableId
|
||||
ctx.body = await handleRequest(appId, DataSourceOperation.CREATE, tableId, { row: inputs })
|
||||
ctx.body = await handleRequest(appId, DataSourceOperation.CREATE, tableId, {
|
||||
row: inputs,
|
||||
})
|
||||
}
|
||||
|
||||
exports.fetchView = async (ctx) => {
|
||||
exports.fetchView = async ctx => {
|
||||
// TODO: don't know what this does for external
|
||||
}
|
||||
|
||||
exports.fetchTableRows = async (ctx) => {
|
||||
exports.fetchTableRows = async ctx => {
|
||||
// TODO: this is a basic read?
|
||||
}
|
||||
|
||||
exports.find = async (ctx) => {
|
||||
exports.find = async ctx => {
|
||||
// TODO: single find
|
||||
}
|
||||
|
||||
exports.destroy = async (ctx) => {
|
||||
exports.destroy = async ctx => {
|
||||
const appId = ctx.appId
|
||||
const tableId = ctx.params.tableId
|
||||
ctx.body = await handleRequest(appId, DataSourceOperation.DELETE, tableId, { id: ctx.request.body._id })
|
||||
ctx.body = await handleRequest(appId, DataSourceOperation.DELETE, tableId, {
|
||||
id: ctx.request.body._id,
|
||||
})
|
||||
}
|
||||
|
||||
exports.bulkDestroy = async (ctx) => {
|
||||
exports.bulkDestroy = async ctx => {
|
||||
// TODO: iterate through rows, build a large OR filter?
|
||||
}
|
||||
|
||||
exports.search = async (ctx) => {
|
||||
exports.search = async ctx => {
|
||||
const appId = ctx.appId
|
||||
const tableId = ctx.params.tableId
|
||||
const { paginate, query, ...params } = ctx.request.body
|
||||
|
@ -90,25 +102,27 @@ exports.search = async (ctx) => {
|
|||
}
|
||||
let sort
|
||||
if (params.sort) {
|
||||
const direction =
|
||||
params.sortOrder === "descending"
|
||||
? SortDirection.DESCENDING
|
||||
: SortDirection.ASCENDING
|
||||
sort = {
|
||||
[params.sort]: params.sortOrder === "descending" ? SortDirection.DESCENDING : SortDirection.ASCENDING
|
||||
[params.sort]: direction,
|
||||
}
|
||||
}
|
||||
ctx.body = await handleRequest(appId, DataSourceOperation.READ, tableId,
|
||||
{
|
||||
filters: query,
|
||||
sort,
|
||||
paginate: paginateObj,
|
||||
}
|
||||
)
|
||||
ctx.body = await handleRequest(appId, DataSourceOperation.READ, tableId, {
|
||||
filters: query,
|
||||
sort,
|
||||
paginate: paginateObj,
|
||||
})
|
||||
}
|
||||
|
||||
exports.validate = async (ctx) => {
|
||||
exports.validate = async ctx => {
|
||||
// can't validate external right now - maybe in future
|
||||
ctx.body = { valid: true }
|
||||
}
|
||||
|
||||
exports.fetchEnrichedRow = async (ctx) => {
|
||||
exports.fetchEnrichedRow = async ctx => {
|
||||
// TODO: should this join?
|
||||
const appId = ctx.appId
|
||||
ctx.body = {}
|
||||
|
|
|
@ -23,7 +23,8 @@ exports.patch = async ctx => {
|
|||
const tableId = getTableId(ctx)
|
||||
try {
|
||||
const { row, table } = await pickApi(tableId).patch(ctx)
|
||||
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
|
||||
ctx.eventEmitter &&
|
||||
ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
|
||||
ctx.message = `${table.name} updated successfully`
|
||||
ctx.body = row
|
||||
} catch (err) {
|
||||
|
@ -104,7 +105,6 @@ exports.search = async ctx => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
exports.validate = async function (ctx) {
|
||||
const tableId = getTableId(ctx)
|
||||
try {
|
||||
|
@ -121,4 +121,4 @@ exports.fetchEnrichedRow = async function (ctx) {
|
|||
} catch (err) {
|
||||
ctx.throw(400, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ exports.save = async function (ctx) {
|
|||
return { row, table }
|
||||
}
|
||||
|
||||
exports.fetchView = async (ctx) => {
|
||||
exports.fetchView = async ctx => {
|
||||
const appId = ctx.appId
|
||||
const viewName = ctx.params.viewName
|
||||
|
||||
|
@ -195,7 +195,7 @@ exports.fetchView = async (ctx) => {
|
|||
return rows
|
||||
}
|
||||
|
||||
exports.fetchTableRows = async (ctx) => {
|
||||
exports.fetchTableRows = async ctx => {
|
||||
const appId = ctx.appId
|
||||
const db = new CouchDB(appId)
|
||||
|
||||
|
@ -215,7 +215,7 @@ exports.fetchTableRows = async (ctx) => {
|
|||
return outputProcessing(appId, table, rows)
|
||||
}
|
||||
|
||||
exports.find = async (ctx) => {
|
||||
exports.find = async ctx => {
|
||||
const appId = ctx.appId
|
||||
const db = new CouchDB(appId)
|
||||
const table = await db.get(ctx.params.tableId)
|
||||
|
@ -246,7 +246,7 @@ exports.destroy = async function (ctx) {
|
|||
await userController.destroyMetadata(ctx)
|
||||
return { response: ctx.body, row }
|
||||
} else {
|
||||
const response = await db.remove(_id, _rev)
|
||||
const response = await db.remove(_id, _rev)
|
||||
return { response, row }
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ exports.search = async ctx => {
|
|||
ctx.body = response
|
||||
}
|
||||
|
||||
exports.validate = async (ctx) => {
|
||||
exports.validate = async ctx => {
|
||||
return validate({
|
||||
appId: ctx.appId,
|
||||
tableId: ctx.params.tableId,
|
||||
|
@ -312,7 +312,7 @@ exports.validate = async (ctx) => {
|
|||
})
|
||||
}
|
||||
|
||||
exports.fetchEnrichedRow = async (ctx) => {
|
||||
exports.fetchEnrichedRow = async ctx => {
|
||||
const appId = ctx.appId
|
||||
const db = new CouchDB(appId)
|
||||
const tableId = ctx.params.tableId
|
||||
|
|
|
@ -43,7 +43,6 @@ exports.SortDirection = {
|
|||
DESCENDING: "DESCENDING",
|
||||
}
|
||||
|
||||
|
||||
exports.USERS_TABLE_SCHEMA = {
|
||||
_id: "ta_users",
|
||||
type: "table",
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
const {
|
||||
DataSourceOperation,
|
||||
SortDirection,
|
||||
} = require("../../constants")
|
||||
const { DataSourceOperation, SortDirection } = require("../../constants")
|
||||
|
||||
const BASE_LIMIT = 5000
|
||||
|
||||
|
@ -50,9 +47,7 @@ function addFilters(query, filters) {
|
|||
return query
|
||||
}
|
||||
|
||||
function buildRelationships() {
|
||||
|
||||
}
|
||||
function buildRelationships() {}
|
||||
|
||||
function buildCreate(knex, json) {
|
||||
const { endpoint, body } = json
|
||||
|
|
|
@ -59,7 +59,6 @@ async function internalQuery(client, sql) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class SqlServerIntegration extends Sql {
|
||||
static pool
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ async function internalQuery(client, sql) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class PostgresIntegration extends Sql {
|
||||
static pool
|
||||
|
||||
|
|
Loading…
Reference in New Issue