mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 02:09:07 +03:00
feat: upd lucid & add more field on fetch user data
This commit is contained in:
parent
f23dd52daa
commit
bb81518fc3
@ -90,4 +90,15 @@ export default class Course extends BaseModel {
|
||||
public static assignCourseId(course: Course) {
|
||||
course.id = nanoid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the `$extras` object
|
||||
*/
|
||||
public serializeExtras() {
|
||||
return {
|
||||
students_count: this.$extras.students_count,
|
||||
likes_count: this.$extras.likes_count,
|
||||
lessons_count: this.$extras.lessons_count,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,9 +34,17 @@ export default class MeService {
|
||||
public async fetchUserData(auth: AuthContract): Promise<IResponse> {
|
||||
const user = await auth.use(this.authGuard).authenticate();
|
||||
|
||||
await user.load('roles');
|
||||
await user.load('contacts');
|
||||
await user.load('courses');
|
||||
await user.load(loader => {
|
||||
loader
|
||||
.load('roles')
|
||||
.load('contacts')
|
||||
.load('courses', q => {
|
||||
q.preload('category');
|
||||
q.withCount('students');
|
||||
q.withCount('likes');
|
||||
q.withCount('lessons');
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
||||
102
package-lock.json
generated
102
package-lock.json
generated
@ -655,23 +655,58 @@
|
||||
}
|
||||
},
|
||||
"@adonisjs/lucid": {
|
||||
"version": "15.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@adonisjs/lucid/-/lucid-15.0.3.tgz",
|
||||
"integrity": "sha512-UbzmyV96X227AOwyXjJNs9/DCRHUl8jCbEJzQwRcQrfFWI0HaIH9crJYKzi1djoQOxXjM+qcTdrd48HDwnb9Vw==",
|
||||
"version": "16.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@adonisjs/lucid/-/lucid-16.0.2.tgz",
|
||||
"integrity": "sha512-t3qh/ehlTPRt0N4qzCZMUsGEqNpzigo+dDzbIC5HwpoBBSE/GCQkcUs5rSFmIllbo49Bxa43SLt1bB6M3RNlRQ==",
|
||||
"requires": {
|
||||
"@poppinss/hooks": "^3.0.4",
|
||||
"@poppinss/utils": "^3.1.3",
|
||||
"@types/faker": "^5.5.6",
|
||||
"@poppinss/hooks": "^3.0.5",
|
||||
"@poppinss/utils": "^3.1.5",
|
||||
"@types/faker": "^5.5.7",
|
||||
"faker": "^5.5.3",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"igniculus": "^1.5.0",
|
||||
"knex": "^0.95.6",
|
||||
"knex": "^0.95.11",
|
||||
"knex-dynamic-connection": "^2.1.1",
|
||||
"luxon": "^1.27.0",
|
||||
"macroable": "^5.1.3",
|
||||
"luxon": "^2.0.1",
|
||||
"macroable": "^5.1.4",
|
||||
"pretty-hrtime": "^1.0.3",
|
||||
"qs": "^6.10.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@poppinss/utils": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@poppinss/utils/-/utils-3.2.0.tgz",
|
||||
"integrity": "sha512-gnqlrxE4zMvqW+LpviyCWCg4+RShCYCFyBdVTyg9ZZEEgPBV9bEY+YB5r/2klFrKx30k9nfClHVI2n8ZKmXgsw==",
|
||||
"requires": {
|
||||
"@types/bytes": "^3.1.1",
|
||||
"@types/he": "^1.1.2",
|
||||
"buffer-alloc": "^1.2.0",
|
||||
"bytes": "^3.1.0",
|
||||
"change-case": "^4.1.2",
|
||||
"cuid": "^2.1.8",
|
||||
"fs-readdir-recursive": "^1.1.0",
|
||||
"he": "^1.2.0",
|
||||
"kind-of": "^6.0.3",
|
||||
"lodash": "^4.17.21",
|
||||
"ms": "^2.1.3",
|
||||
"pluralize": "^8.0.0",
|
||||
"require-all": "^3.0.0",
|
||||
"resolve-from": "^5.0.0",
|
||||
"slugify": "^1.6.0",
|
||||
"truncatise": "0.0.8"
|
||||
}
|
||||
},
|
||||
"luxon": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/luxon/-/luxon-2.0.2.tgz",
|
||||
"integrity": "sha512-ZRioYLCgRHrtTORaZX1mx+jtxKtKuI5ZDvHNAmqpUzGqSrR+tL4FVLn/CUGMA3h0+AKD1MAxGI5GnCqR5txNqg=="
|
||||
},
|
||||
"slugify": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.0.tgz",
|
||||
"integrity": "sha512-FkMq+MQc5hzYgM86nLuHI98Acwi3p4wX+a5BO9Hhw4JdK4L7WueIiZ4tXEobImPqBz2sVcV0+Mu3GRB30IGang=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@adonisjs/mail": {
|
||||
@ -1225,9 +1260,9 @@
|
||||
}
|
||||
},
|
||||
"@poppinss/hooks": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@poppinss/hooks/-/hooks-3.0.4.tgz",
|
||||
"integrity": "sha512-vVtd8v3grQ0JcbZgvUrUIUeMqTcHkE31nJGE/jRxDEbCiusBwBJD6D16a5Wzbl+o6xRldlhIcdDn+AE8PUpuVA=="
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@poppinss/hooks/-/hooks-3.0.5.tgz",
|
||||
"integrity": "sha512-kazQstmIPq4n7/qjk5ms9SEiXtLEJ+EMZXxyXTupTVq7URFIUeULgXFv/F3vheLPCSzfByu/L2iO7M457RjszQ=="
|
||||
},
|
||||
"@poppinss/inspect": {
|
||||
"version": "1.0.1",
|
||||
@ -1344,9 +1379,9 @@
|
||||
}
|
||||
},
|
||||
"@types/faker": {
|
||||
"version": "5.5.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/faker/-/faker-5.5.7.tgz",
|
||||
"integrity": "sha512-ejzb61Q5zQTtS0ZIafgQ7ahO5ACzmGhG5PfX2hxWyth3k0/aysb4ZOxKQB8DbzwSPppA5jmFBwqnBxjv5hqI5Q=="
|
||||
"version": "5.5.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/faker/-/faker-5.5.8.tgz",
|
||||
"integrity": "sha512-bsl0rYsaZVHlZkynL5O04q6YXDmVjcid6MbOHWqvtE2WWs/EKhp0qchDDhVWlWyQXUffX1G83X9LnMxRl8S/Mw=="
|
||||
},
|
||||
"@types/fs-extra": {
|
||||
"version": "9.0.12",
|
||||
@ -4712,20 +4747,20 @@
|
||||
"integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA=="
|
||||
},
|
||||
"knex": {
|
||||
"version": "0.95.6",
|
||||
"resolved": "https://registry.npmjs.org/knex/-/knex-0.95.6.tgz",
|
||||
"integrity": "sha512-noRcmkJl1MdicUbezrcr8OtVLcqQ/cfLIwgAx5EaxNxQOIJff88rBeyLywUScGhQNd/b78DIKKXZzLMrm6h/cw==",
|
||||
"version": "0.95.11",
|
||||
"resolved": "https://registry.npmjs.org/knex/-/knex-0.95.11.tgz",
|
||||
"integrity": "sha512-grDetD91O8VoQVCFqeWTgkzdq5406W6rggF/lK1hHuwzmjDs/0m9KxyncGdZbklTi7aUgHvw3+Cfy4x7FvpdaQ==",
|
||||
"requires": {
|
||||
"colorette": "1.2.1",
|
||||
"commander": "^7.1.0",
|
||||
"debug": "4.3.1",
|
||||
"debug": "4.3.2",
|
||||
"escalade": "^3.1.1",
|
||||
"esm": "^3.2.25",
|
||||
"getopts": "2.2.5",
|
||||
"interpret": "^2.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"pg-connection-string": "2.4.0",
|
||||
"rechoir": "^0.7.0",
|
||||
"pg-connection-string": "2.5.0",
|
||||
"rechoir": "0.7.0",
|
||||
"resolve-from": "^5.0.0",
|
||||
"tarn": "^3.0.1",
|
||||
"tildify": "2.0.0"
|
||||
@ -4736,23 +4771,10 @@
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
|
||||
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
|
||||
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
|
||||
"requires": {
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
},
|
||||
"getopts": {
|
||||
"version": "2.2.5",
|
||||
"resolved": "https://registry.npmjs.org/getopts/-/getopts-2.2.5.tgz",
|
||||
"integrity": "sha512-9jb7AW5p3in+IiJWhQiZmmwkpLaR/ccTWdWQCtZM66HJcHHLegowh4q4tSD7gouUyeNvFWRavfK9GXosQHDpFA=="
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -4897,9 +4919,9 @@
|
||||
"integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ=="
|
||||
},
|
||||
"macroable": {
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/macroable/-/macroable-5.1.3.tgz",
|
||||
"integrity": "sha512-vLcoI4Ajn1FqTrO8wJL8wBd8eTXsuzAGpcGmQaWbK7YLrFUhTV69WwAEnyT03HpnwgJL2wzZm6lg6sOJHGTQXA=="
|
||||
"version": "5.1.4",
|
||||
"resolved": "https://registry.npmjs.org/macroable/-/macroable-5.1.4.tgz",
|
||||
"integrity": "sha512-6yOJQT7QhYlJqhNWn/B2h+1ylsCnL8dMBmBpdnVNK+02PfQm13Ix4Szx4HiS3rp4a28EKckCGW27gtTZoYXYYQ=="
|
||||
},
|
||||
"make-dir": {
|
||||
"version": "3.1.0",
|
||||
@ -5855,9 +5877,9 @@
|
||||
}
|
||||
},
|
||||
"pg-connection-string": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz",
|
||||
"integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz",
|
||||
"integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ=="
|
||||
},
|
||||
"pg-int8": {
|
||||
"version": "1.0.1",
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
"@adonisjs/auth": "^8.0.9",
|
||||
"@adonisjs/core": "^5.3.2",
|
||||
"@adonisjs/drive": "^2.0.6",
|
||||
"@adonisjs/lucid": "^15.0.3",
|
||||
"@adonisjs/lucid": "^16.0.2",
|
||||
"@adonisjs/mail": "^7.2.4",
|
||||
"@adonisjs/redis": "^7.0.9",
|
||||
"@adonisjs/repl": "^3.1.6",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user