user search
This commit is contained in:
parent
7ef56de1be
commit
36f3bbf6dd
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,6 @@
|
|||
|
||||
const rimraf = require("rimraf")
|
||||
const { join, resolve } = require("path")
|
||||
// const run = require("../../cli/src/commands/run/runHandler")
|
||||
const initialiseBudibase = require("../../server/src/utilities/initialiseBudibase")
|
||||
|
||||
const homedir = join(require("os").homedir(), ".budibase")
|
||||
|
|
|
@ -4,7 +4,6 @@ import { backendUiStore, store } from "builderStore"
|
|||
import { findAllMatchingComponents, findComponentPath } from "./storeUtils"
|
||||
import { makePropSafe } from "@budibase/string-templates"
|
||||
import { TableNames } from "../constants"
|
||||
import { search } from "../../../server/src/api/controllers/row"
|
||||
|
||||
// Regex to match all instances of template strings
|
||||
const CAPTURE_VAR_INSIDE_TEMPLATE = /{{([^}]+)}}/g
|
||||
|
|
|
@ -233,35 +233,27 @@ exports.createIndex = async function(ctx) {
|
|||
const appId = "app_1987903cf3604d459969c80cf17651a0"
|
||||
const db = new CouchDB(appId)
|
||||
|
||||
// ctx.body = await db.get("_design/search_ddoc")
|
||||
ctx.body = await db.createIndex({
|
||||
index: {
|
||||
fields: ctx.request.body.fields,
|
||||
name: "search_index",
|
||||
name: "other_search_index",
|
||||
ddoc: "search_ddoc",
|
||||
type: "json",
|
||||
},
|
||||
})
|
||||
// ctx.body = await db.getIndexes()
|
||||
}
|
||||
|
||||
exports.search = async function(ctx) {
|
||||
// const appId = ctx.user.appId
|
||||
const appId = "app_1987903cf3604d459969c80cf17651a0"
|
||||
|
||||
// const { pageSize = 10, cursor } = ctx.query
|
||||
|
||||
// special case for users, fetch through the user controller
|
||||
// let rows
|
||||
// SHOULD WE PREVENT SEARCHING FOR USERS?
|
||||
// if (ctx.params.tableId === ViewNames.USERS) {
|
||||
// await usersController.fetch(ctx)
|
||||
// rows = ctx.body
|
||||
// } else {
|
||||
const appId = ctx.user.appId
|
||||
// const appId = "app_1987903cf3604d459969c80cf17651a0"
|
||||
|
||||
const db = new CouchDB(appId)
|
||||
|
||||
const {
|
||||
query,
|
||||
pagination: { pageSize = 10, cursor, reverse },
|
||||
pagination: { pageSize = 10, cursor },
|
||||
} = ctx.request.body
|
||||
|
||||
query.tableId = ctx.params.tableId
|
||||
|
@ -277,8 +269,16 @@ exports.search = async function(ctx) {
|
|||
sort: ["_id"],
|
||||
skip: 1,
|
||||
})
|
||||
|
||||
const rows = response.docs
|
||||
|
||||
// delete passwords from users
|
||||
if (query.tableId === ViewNames.USERS) {
|
||||
for (let row of rows) {
|
||||
delete row.password
|
||||
}
|
||||
}
|
||||
|
||||
ctx.body = await linkRows.attachLinkInfo(appId, rows)
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,18 @@ async function checkForColumnUpdates(db, oldTable, updatedTable) {
|
|||
return updatedRows
|
||||
}
|
||||
|
||||
async function updateSearchIndex(fields) {
|
||||
console.log("Updating stuff")
|
||||
const resp = await db.createIndex({
|
||||
index: {
|
||||
fields,
|
||||
name: "search_index",
|
||||
ddoc: "search_ddoc",
|
||||
type: "json",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
exports.fetch = async function(ctx) {
|
||||
const db = new CouchDB(ctx.user.appId)
|
||||
const body = await db.allDocs(
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue