generated from unjs/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1afa2ec
commit 099ce1a
Showing
6 changed files
with
57 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"extends": ["eslint-config-unjs"], | ||
"rules": {} | ||
"rules": { | ||
"unicorn/filename-case": "off", | ||
"@typescript-eslint/consistent-type-imports": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
{ | ||
"name": "packageName", | ||
"version": "0.0.0", | ||
"name": "@planetadeleste/pinia-orm-core", | ||
"version": "1.0.0", | ||
"description": "", | ||
"repository": "unjs/packageName", | ||
"repository":{ | ||
"type": "git", | ||
"url": "git+https://github.com/planetadeleste/pinia-orm-core.git" | ||
}, | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"type": "module", | ||
|
@@ -31,7 +34,9 @@ | |
"test:types": "tsc --noEmit --skipLibCheck" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.202", | ||
"@types/node": "^20.10.5", | ||
"@types/uuid": "^9.0.7", | ||
"@vitest/coverage-v8": "^1.1.0", | ||
"changelogen": "^0.5.5", | ||
"eslint": "^8.56.0", | ||
|
@@ -42,5 +47,11 @@ | |
"unbuild": "^2.0.0", | ||
"vitest": "^1.1.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"lodash": "^4.17.21", | ||
"pinia": "^2.1.7", | ||
"pinia-orm": "^1.7.2", | ||
"uuid": "^9.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { isEmpty, startsWith } from "lodash"; | ||
import type { Element } from "pinia-orm"; | ||
import { Model as BaseModel } from "pinia-orm"; | ||
import { v4 } from "uuid"; | ||
|
||
interface Model<T extends Element = Element> extends BaseModel { | ||
id: string | number; | ||
created_at?: string; | ||
updated_at?: string; | ||
uuid: boolean; | ||
} | ||
|
||
class Model<T extends Element = Element> extends BaseModel { | ||
static baseUrl: string; | ||
static uuid = false; | ||
|
||
static creating<M extends Model = Model>(model: M) { | ||
if (model.uuid && isEmpty(model.$getIndexId())) { | ||
model.id = `-${v4()}`; | ||
} | ||
} | ||
|
||
$isNew(): boolean { | ||
return !this.id || startsWith(this.id as string, "-") || !this.created_at; | ||
} | ||
} | ||
|
||
export default Model; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export function test() { | ||
return "works!"; | ||
} | ||
export { default as Model } from "./Model"; |