Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Bruno Predot
/
tmdb_test
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Bruno Predot
2025-04-23 23:06:22 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
960de4f12b49371e2b7f29a1cf896726f4e46447
960de4f1
1 parent
9eb7c522
Ajout du du model Movie.
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
1 deletions
CHANGELOG_RELEASE.md
components/MoviesList.vue
models/movie.ts
CHANGELOG_RELEASE.md
View file @
960de4f
...
...
@@ -5,3 +5,5 @@
-
Création du composant MoviesList.
-
Création du composant SearchBar.
-
Création du composant SkeletonMoviesLoader.
-
Installation et paramétrage de pinia-orm.
-
Ajout du du model Movie.
\ No newline at end of file
...
...
components/MoviesList.vue
View file @
960de4f
...
...
@@ -3,6 +3,7 @@
import SearchBar from "~/components/SearchBar.vue";
import { ref } from "vue";
import { useTMDB } from "~/composables/tMDB";
import { Movie } from "~/models/movie";
//#endregion
//#region --Declaration--.
...
...
@@ -33,13 +34,14 @@ const fetchMovies = async (page: number) => {
try {
isLoadingMore.value = true;
const data = await fetchPopularMovies(page);
console.log("data in fetchMovies", data);
if (page === 1) {
movies.value = data.results;
} else {
movies.value = [...movies.value, ...data.results];
}
// Save in Movie model.
useRepo(Movie).save(data.results);
totalPages.value = data.total_pages;
currentPage.value = page;
...
...
models/movie.ts
0 → 100644
View file @
960de4f
import
{
Model
}
from
"pinia-orm"
;
export
class
Movie
extends
Model
{
/**
*
* @return {string}
*/
static
get
entity
()
{
return
"Movie"
;
}
/**
*
* @return {string}
*/
static
get
primaryKey
()
{
return
"id"
;
}
static
fields
()
{
return
{
// Attributs.
id
:
this
.
number
(
null
),
adult
:
this
.
boolean
(
false
),
backdrop_pat
:
this
.
string
(
null
),
genre_ids
:
this
.
attr
([]),
original_language
:
this
.
string
(
null
),
original_title
:
this
.
string
(
null
),
overview
:
this
.
string
(
null
),
popularity
:
this
.
number
(
null
),
poster_path
:
this
.
string
(
null
),
release_date
:
this
.
string
(
null
),
title
:
this
.
string
(
null
),
video
:
this
.
boolean
(
false
),
vote_average
:
this
.
number
(
null
),
vote_count
:
this
.
number
(
null
),
// Relations.
};
}
static
piniaOptions
=
{
persist
:
true
,
};
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment