tauri-plugin-mongoose 0.2.2 → 0.2.4
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.
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +22 -3
- package/dist/index.mjs +22 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -56,7 +56,11 @@ interface ConnectOptions {
|
|
|
56
56
|
url: string;
|
|
57
57
|
dbName?: string;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
interface ConnectCallbacks {
|
|
60
|
+
onSuccess?: () => void;
|
|
61
|
+
onError?: (error: string) => void;
|
|
62
|
+
}
|
|
63
|
+
declare function connect(options: ConnectOptions, callbacks?: ConnectCallbacks): Promise<void>;
|
|
64
|
+
declare function connect(url: string, dbName?: string, callbacks?: ConnectCallbacks): Promise<void>;
|
|
61
65
|
|
|
62
|
-
export { type ConnectOptions, type InferSchemaType, Model, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect };
|
|
66
|
+
export { type ConnectCallbacks, type ConnectOptions, type InferSchemaType, Model, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect };
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,11 @@ interface ConnectOptions {
|
|
|
56
56
|
url: string;
|
|
57
57
|
dbName?: string;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
interface ConnectCallbacks {
|
|
60
|
+
onSuccess?: () => void;
|
|
61
|
+
onError?: (error: string) => void;
|
|
62
|
+
}
|
|
63
|
+
declare function connect(options: ConnectOptions, callbacks?: ConnectCallbacks): Promise<void>;
|
|
64
|
+
declare function connect(url: string, dbName?: string, callbacks?: ConnectCallbacks): Promise<void>;
|
|
61
65
|
|
|
62
|
-
export { type ConnectOptions, type InferSchemaType, Model, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect };
|
|
66
|
+
export { type ConnectCallbacks, type ConnectOptions, type InferSchemaType, Model, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect };
|
package/dist/index.js
CHANGED
|
@@ -142,11 +142,30 @@ var Model = class {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
// index.ts
|
|
145
|
-
async function connect(urlOrOptions,
|
|
145
|
+
async function connect(urlOrOptions, dbNameOrCallbacks, callbacks) {
|
|
146
|
+
let url;
|
|
147
|
+
let dbName;
|
|
148
|
+
let cbs;
|
|
146
149
|
if (typeof urlOrOptions === "string") {
|
|
147
|
-
|
|
150
|
+
url = urlOrOptions;
|
|
151
|
+
if (typeof dbNameOrCallbacks === "string") {
|
|
152
|
+
dbName = dbNameOrCallbacks;
|
|
153
|
+
cbs = callbacks;
|
|
154
|
+
} else {
|
|
155
|
+
cbs = dbNameOrCallbacks;
|
|
156
|
+
}
|
|
148
157
|
} else {
|
|
149
|
-
|
|
158
|
+
url = urlOrOptions.url;
|
|
159
|
+
dbName = urlOrOptions.dbName;
|
|
160
|
+
cbs = dbNameOrCallbacks;
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
await (0, import_core2.invoke)("plugin:mongoose|connect", { url, dbName });
|
|
164
|
+
cbs?.onSuccess?.();
|
|
165
|
+
} catch (error) {
|
|
166
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
167
|
+
cbs?.onError?.(errorMessage);
|
|
168
|
+
throw error;
|
|
150
169
|
}
|
|
151
170
|
}
|
|
152
171
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -117,11 +117,30 @@ var Model = class {
|
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
// index.ts
|
|
120
|
-
async function connect(urlOrOptions,
|
|
120
|
+
async function connect(urlOrOptions, dbNameOrCallbacks, callbacks) {
|
|
121
|
+
let url;
|
|
122
|
+
let dbName;
|
|
123
|
+
let cbs;
|
|
121
124
|
if (typeof urlOrOptions === "string") {
|
|
122
|
-
|
|
125
|
+
url = urlOrOptions;
|
|
126
|
+
if (typeof dbNameOrCallbacks === "string") {
|
|
127
|
+
dbName = dbNameOrCallbacks;
|
|
128
|
+
cbs = callbacks;
|
|
129
|
+
} else {
|
|
130
|
+
cbs = dbNameOrCallbacks;
|
|
131
|
+
}
|
|
123
132
|
} else {
|
|
124
|
-
|
|
133
|
+
url = urlOrOptions.url;
|
|
134
|
+
dbName = urlOrOptions.dbName;
|
|
135
|
+
cbs = dbNameOrCallbacks;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
await invoke2("plugin:mongoose|connect", { url, dbName });
|
|
139
|
+
cbs?.onSuccess?.();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
142
|
+
cbs?.onError?.(errorMessage);
|
|
143
|
+
throw error;
|
|
125
144
|
}
|
|
126
145
|
}
|
|
127
146
|
export {
|