user search
This commit is contained in:
parent
d2bd2209eb
commit
fde5ef02ac
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
const rimraf = require("rimraf")
|
const rimraf = require("rimraf")
|
||||||
const { join, resolve } = require("path")
|
const { join, resolve } = require("path")
|
||||||
// const run = require("../../cli/src/commands/run/runHandler")
|
|
||||||
const initialiseBudibase = require("../../server/src/utilities/initialiseBudibase")
|
const initialiseBudibase = require("../../server/src/utilities/initialiseBudibase")
|
||||||
|
|
||||||
const homedir = join(require("os").homedir(), ".budibase")
|
const homedir = join(require("os").homedir(), ".budibase")
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { backendUiStore, store } from "builderStore"
|
||||||
import { findAllMatchingComponents, findComponentPath } from "./storeUtils"
|
import { findAllMatchingComponents, findComponentPath } from "./storeUtils"
|
||||||
import { makePropSafe } from "@budibase/string-templates"
|
import { makePropSafe } from "@budibase/string-templates"
|
||||||
import { TableNames } from "../constants"
|
import { TableNames } from "../constants"
|
||||||
import { search } from "../../../server/src/api/controllers/row"
|
|
||||||
|
|
||||||
// Regex to match all instances of template strings
|
// Regex to match all instances of template strings
|
||||||
const CAPTURE_VAR_INSIDE_TEMPLATE = /{{([^}]+)}}/g
|
const CAPTURE_VAR_INSIDE_TEMPLATE = /{{([^}]+)}}/g
|
||||||
|
|
|
@ -233,35 +233,27 @@ exports.createIndex = async function(ctx) {
|
||||||
const appId = "app_1987903cf3604d459969c80cf17651a0"
|
const appId = "app_1987903cf3604d459969c80cf17651a0"
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
|
|
||||||
|
// ctx.body = await db.get("_design/search_ddoc")
|
||||||
ctx.body = await db.createIndex({
|
ctx.body = await db.createIndex({
|
||||||
index: {
|
index: {
|
||||||
fields: ctx.request.body.fields,
|
fields: ctx.request.body.fields,
|
||||||
name: "search_index",
|
name: "other_search_index",
|
||||||
ddoc: "search_ddoc",
|
ddoc: "search_ddoc",
|
||||||
type: "json",
|
type: "json",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
// ctx.body = await db.getIndexes()
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.search = async function(ctx) {
|
exports.search = async function(ctx) {
|
||||||
// const appId = ctx.user.appId
|
const appId = ctx.user.appId
|
||||||
const appId = "app_1987903cf3604d459969c80cf17651a0"
|
// 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 db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
query,
|
query,
|
||||||
pagination: { pageSize = 10, cursor, reverse },
|
pagination: { pageSize = 10, cursor },
|
||||||
} = ctx.request.body
|
} = ctx.request.body
|
||||||
|
|
||||||
query.tableId = ctx.params.tableId
|
query.tableId = ctx.params.tableId
|
||||||
|
@ -277,8 +269,16 @@ exports.search = async function(ctx) {
|
||||||
sort: ["_id"],
|
sort: ["_id"],
|
||||||
skip: 1,
|
skip: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
const rows = response.docs
|
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)
|
ctx.body = await linkRows.attachLinkInfo(appId, rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,18 @@ async function checkForColumnUpdates(db, oldTable, updatedTable) {
|
||||||
return updatedRows
|
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) {
|
exports.fetch = async function(ctx) {
|
||||||
const db = new CouchDB(ctx.user.appId)
|
const db = new CouchDB(ctx.user.appId)
|
||||||
const body = await db.allDocs(
|
const body = await db.allDocs(
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue