Add endpoint for full-text search (#6)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
2020-10-12 21:46:50 -05:00
parent 273460b126
commit e55720e3bb
7 changed files with 100 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ class Node extends Model {
// Static and instance methods can go here
get page() {
const Page = this.models.get('api:Page')
return this.belongs_to_one(Page, "PageId", "_id")
return this.belongs_to_one(Page, "PageId", "UUID")
}
to_html() {

View File

@@ -21,6 +21,36 @@ class User extends AuthUser {
return Page.findOne({OrgUserId: this._id, ParentId: '0'})
}
async get_accessible_pages() {
const Page = this.models.get('api:Page')
const user_page = await this.get_root_page()
const user_pages = await user_page.visible_flat_children(this)
let view_pages = await Page.find({ shared_users_view: this._id })
for ( const page of view_pages ) {
view_pages = [...view_pages, ...(await page.visible_flat_children(this))]
}
let update_pages = await Page.find({ shared_users_update: this._id })
for ( const page of update_pages ) {
update_pages = [...update_pages, ...(await page.visible_flat_children(this))]
}
let manage_pages = await Page.find({ shared_users_manage: this._id })
for ( const page of manage_pages ) {
manage_pages = [...manage_pages, ...(await page.visible_flat_children(this))]
}
const all_pages = [...user_pages, ...view_pages, ...update_pages, ...manage_pages].filter(x => !x.virtual)
const uniq_page_obj = {}
for ( const page of all_pages ) {
uniq_page_obj[page.UUID] = page
}
return Object.values(uniq_page_obj)
}
// Other members and methods here
}