forked from geolba/tethys.backend
initial commit
This commit is contained in:
commit
4fc3bb0a01
202 changed files with 41729 additions and 0 deletions
23
app/Controllers/Http/Api/AuthorsController.ts
Normal file
23
app/Controllers/Http/Api/AuthorsController.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
|
||||
import Person from 'App/Models/Person';
|
||||
// import Dataset from 'App/Models/Dataset';
|
||||
|
||||
// node ace make:controller Author
|
||||
export default class AuthorsController {
|
||||
|
||||
public async index({}: HttpContextContract) {
|
||||
// select * from gba.persons
|
||||
// where exists (select * from gba.documents inner join gba.link_documents_persons on "documents"."id" = "link_documents_persons"."document_id"
|
||||
// where ("link_documents_persons"."role" = 'author') and ("persons"."id" = "link_documents_persons"."person_id"));
|
||||
const authors = await Person.query()
|
||||
.whereHas('datasets', (dQuery) => {
|
||||
dQuery.wherePivot('role', 'author')
|
||||
})
|
||||
.withCount('datasets', (query) => {
|
||||
query.as('datasets_count')
|
||||
});
|
||||
|
||||
return authors;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue