|
|
@@ -1,4 +1,4 @@
|
|
|
-import {Query as VuexQuery} from "@vuex-orm/core";
|
|
|
+import {Query as VuexQuery, Model} from "@vuex-orm/core";
|
|
|
import {$objectProperties} from "~/services/utils/objectProperties";
|
|
|
import {AnyJson} from "~/types/interfaces";
|
|
|
import {Collection, Item} from "@vuex-orm/core/dist/src/data/Data";
|
|
|
@@ -24,6 +24,19 @@ class Query{
|
|
|
return item;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupération du premier item
|
|
|
+ * @param {VuexQuery} query
|
|
|
+ * @return {Item} l'Item
|
|
|
+ */
|
|
|
+ public getFirstItem(query: VuexQuery): Item{
|
|
|
+ const item = query.first()
|
|
|
+ if(!item || typeof item === "undefined")
|
|
|
+ throw new Error('item not found')
|
|
|
+
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Récupération la collection de la Query
|
|
|
* @param {VuexQuery} query
|