@avion-block/nuxt-mongoose 1.1.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +139 -0
  2. package/dist/client/200.html +1 -0
  3. package/dist/client/404.html +1 -0
  4. package/dist/client/_nuxt/Be_8YVmd.js +1 -0
  5. package/dist/client/_nuxt/BgqxMV_S.js +1 -0
  6. package/dist/client/_nuxt/BhG4bLuH.js +1 -0
  7. package/dist/client/_nuxt/C1_0osGQ.js +4 -0
  8. package/dist/client/_nuxt/DKP8g6aG.js +1 -0
  9. package/dist/client/_nuxt/DLYYGG6i.js +1 -0
  10. package/dist/client/_nuxt/Dg51sM1p.js +1 -0
  11. package/dist/client/_nuxt/builds/latest.json +1 -0
  12. package/dist/client/_nuxt/builds/meta/9f2a79dd-102e-4943-be21-dd8083c43b3d.json +1 -0
  13. package/dist/client/_nuxt/entry.Cp4I88Tv.css +1 -0
  14. package/dist/client/_nuxt/error-404.Dmi5Qu-g.css +1 -0
  15. package/dist/client/_nuxt/error-500.BMT8OSvZ.css +1 -0
  16. package/dist/client/_nuxt/index.DZHRaZYA.css +1 -0
  17. package/dist/client/index.html +1 -0
  18. package/dist/module.d.mts +43 -0
  19. package/dist/module.json +9 -0
  20. package/dist/module.mjs +413 -0
  21. package/dist/runtime/server/plugins/mongoose.db.d.ts +2 -0
  22. package/dist/runtime/server/plugins/mongoose.db.js +4 -0
  23. package/dist/runtime/server/services/connection.d.ts +5 -0
  24. package/dist/runtime/server/services/connection.js +24 -0
  25. package/dist/runtime/server/services/discriminator.d.ts +9 -0
  26. package/dist/runtime/server/services/discriminator.js +18 -0
  27. package/dist/runtime/server/services/index.d.ts +3 -0
  28. package/dist/runtime/server/services/index.js +3 -0
  29. package/dist/runtime/server/services/model.d.ts +8 -0
  30. package/dist/runtime/server/services/model.js +17 -0
  31. package/dist/runtime/server/tsconfig.json +3 -0
  32. package/dist/types.d.mts +3 -0
  33. package/package.json +88 -0
@@ -0,0 +1,18 @@
1
+ import mongoose from "mongoose";
2
+ export function defineMongooseDiscriminatorModel(nameOrOptions, baseModel, schema, options, hooks) {
3
+ let name;
4
+ if (typeof nameOrOptions === "string") {
5
+ name = nameOrOptions;
6
+ } else {
7
+ name = nameOrOptions.name;
8
+ baseModel = nameOrOptions.baseModel;
9
+ schema = nameOrOptions.schema;
10
+ options = nameOrOptions.options;
11
+ hooks = nameOrOptions.hooks;
12
+ }
13
+ const newSchema = new mongoose.Schema(schema, options);
14
+ if (hooks) {
15
+ hooks(newSchema);
16
+ }
17
+ return baseModel.discriminator(name, newSchema);
18
+ }
@@ -0,0 +1,3 @@
1
+ export { defineMongooseConnection } from "./connection.js";
2
+ export { defineMongooseModel } from "./model.js";
3
+ export { defineMongooseDiscriminatorModel } from "./discriminator.js";
@@ -0,0 +1,3 @@
1
+ export { defineMongooseConnection } from "./connection.js";
2
+ export { defineMongooseModel } from "./model.js";
3
+ export { defineMongooseDiscriminatorModel } from "./discriminator.js";
@@ -0,0 +1,8 @@
1
+ import type { Model, SchemaDefinition, SchemaOptions } from "mongoose";
2
+ import mongoose from "mongoose";
3
+ export declare function defineMongooseModel<T>(nameOrOptions: string | {
4
+ name: string;
5
+ schema: SchemaDefinition<T>;
6
+ options?: SchemaOptions;
7
+ hooks?: (schema: mongoose.Schema<T>) => void;
8
+ }, schema?: SchemaDefinition<T>, options?: SchemaOptions, hooks?: (schema: mongoose.Schema<T>) => void): Model<T>;
@@ -0,0 +1,17 @@
1
+ import mongoose from "mongoose";
2
+ export function defineMongooseModel(nameOrOptions, schema, options, hooks) {
3
+ let name;
4
+ if (typeof nameOrOptions === "string") {
5
+ name = nameOrOptions;
6
+ } else {
7
+ name = nameOrOptions.name;
8
+ schema = nameOrOptions.schema;
9
+ options = nameOrOptions.options;
10
+ hooks = nameOrOptions.hooks;
11
+ }
12
+ const newSchema = new mongoose.Schema(schema, options);
13
+ if (hooks) {
14
+ hooks(newSchema);
15
+ }
16
+ return mongoose.model(name, newSchema);
17
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.server.json",
3
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@avion-block/nuxt-mongoose",
3
+ "type": "module",
4
+ "version": "1.1.0-dev.0",
5
+ "private": false,
6
+ "description": "Nuxt 3 module for MongoDB with Mongoose",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/sponsors/arashsheyda",
9
+ "homepage": "https://docs.arashsheyda.me/nuxt-mongoose",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/AvionBlock/nuxt-mongoose.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/AvionBlock/nuxt-mongoose/issues"
16
+ },
17
+ "keywords": [
18
+ "nuxt",
19
+ "mongoose",
20
+ "mongodb",
21
+ "devtools"
22
+ ],
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/types.d.mts",
26
+ "import": "./dist/module.mjs"
27
+ }
28
+ },
29
+ "build": {
30
+ "externals": [
31
+ "ofetch"
32
+ ]
33
+ },
34
+ "main": "./dist/module.mjs",
35
+ "typesVersions": {
36
+ "*": {
37
+ ".": [
38
+ "./dist/types.d.mts"
39
+ ]
40
+ }
41
+ },
42
+ "files": [
43
+ "dist"
44
+ ],
45
+ "scripts": {
46
+ "prepack": "pnpm build && pnpm build:client",
47
+ "build": "nuxt-module-build build",
48
+ "build:client": "nuxi generate client",
49
+ "dev": "nuxi dev playground",
50
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare client && nuxi prepare playground",
51
+ "dev:client": "nuxi dev client --port 3300",
52
+ "preview": "pnpm prepack && pnpm dev",
53
+ "release": "pnpm run lint && pnpm run test && pnpm run build && changelogen --release && pnpm publish",
54
+ "lint": "eslint .",
55
+ "lint:fix": "eslint . --fix",
56
+ "test": "vitest run",
57
+ "test:watch": "vitest watch",
58
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
59
+ },
60
+ "dependencies": {
61
+ "@nuxt/devtools-kit": "^3.2.2",
62
+ "@nuxt/devtools-ui-kit": "^3.2.2",
63
+ "@nuxt/kit": "^4.2.2",
64
+ "@vueuse/core": "^14.2.1",
65
+ "defu": "^6.1.4",
66
+ "fs-extra": "^11.3.4",
67
+ "mongoose": "^9.2.4",
68
+ "ofetch": "^1.5.1",
69
+ "pathe": "^2.0.3",
70
+ "pluralize": "^8.0.0",
71
+ "sirv": "^3.0.2"
72
+ },
73
+ "devDependencies": {
74
+ "@nuxt/eslint-config": "^1.12.1",
75
+ "@nuxt/module-builder": "^1.0.2",
76
+ "@nuxt/test-utils": "^4.0.0",
77
+ "@types/fs-extra": "^11.0.4",
78
+ "@types/pluralize": "^0.0.33",
79
+ "changelogen": "^0.6.2",
80
+ "eslint": "^10.0.2",
81
+ "nuxt": "^4.3.1",
82
+ "sass": "^1.97.3",
83
+ "typescript": "^5.9.3",
84
+ "vitest": "^4.0.18",
85
+ "vue-tsc": "^3.2.5"
86
+ },
87
+ "packageManager": "pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017"
88
+ }