tauri-plugin-mongoose 0.2.8 → 0.2.9

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 CHANGED
@@ -49,6 +49,16 @@ declare class Model {
49
49
  constructor(name: string, schema: Schema);
50
50
  getById(id: string): Promise<InferSchemaType<typeof this.schema>>;
51
51
  validate(doc: InferSchemaType<typeof this.schema>): Promise<InferSchemaType<Schema>>;
52
+ find(filter?: object, options?: {
53
+ limit?: number;
54
+ skip?: number;
55
+ page?: number;
56
+ sort?: object;
57
+ }): Promise<InferSchemaType<typeof this.schema>[]>;
58
+ findOne(filter?: object, options?: {
59
+ skip?: number;
60
+ sort?: object;
61
+ }): Promise<InferSchemaType<typeof this.schema> | null>;
52
62
  create(doc: InferSchemaType<typeof this.schema>): Promise<InferSchemaType<typeof this.schema>>;
53
63
  }
54
64
 
package/dist/index.d.ts CHANGED
@@ -49,6 +49,16 @@ declare class Model {
49
49
  constructor(name: string, schema: Schema);
50
50
  getById(id: string): Promise<InferSchemaType<typeof this.schema>>;
51
51
  validate(doc: InferSchemaType<typeof this.schema>): Promise<InferSchemaType<Schema>>;
52
+ find(filter?: object, options?: {
53
+ limit?: number;
54
+ skip?: number;
55
+ page?: number;
56
+ sort?: object;
57
+ }): Promise<InferSchemaType<typeof this.schema>[]>;
58
+ findOne(filter?: object, options?: {
59
+ skip?: number;
60
+ sort?: object;
61
+ }): Promise<InferSchemaType<typeof this.schema> | null>;
52
62
  create(doc: InferSchemaType<typeof this.schema>): Promise<InferSchemaType<typeof this.schema>>;
53
63
  }
54
64
 
package/dist/index.js CHANGED
@@ -135,6 +135,25 @@ var Model = class {
135
135
  }
136
136
  return doc;
137
137
  }
138
+ async find(filter = {}, options = {}) {
139
+ const docs = await (0, import_core.invoke)("plugin:mongoose|find", {
140
+ collection: this.name,
141
+ filter,
142
+ options
143
+ });
144
+ return Promise.all(docs.map((doc) => this.validate(doc)));
145
+ }
146
+ async findOne(filter = {}, options = {}) {
147
+ const doc = await (0, import_core.invoke)("plugin:mongoose|find_one", {
148
+ collection: this.name,
149
+ filter,
150
+ options
151
+ });
152
+ if (doc) {
153
+ return this.validate(doc);
154
+ }
155
+ return null;
156
+ }
138
157
  async create(doc) {
139
158
  const validatedDoc = await this.validate(doc);
140
159
  return await (0, import_core.invoke)("plugin:mongoose|create", {
package/dist/index.mjs CHANGED
@@ -107,6 +107,25 @@ var Model = class {
107
107
  }
108
108
  return doc;
109
109
  }
110
+ async find(filter = {}, options = {}) {
111
+ const docs = await invoke("plugin:mongoose|find", {
112
+ collection: this.name,
113
+ filter,
114
+ options
115
+ });
116
+ return Promise.all(docs.map((doc) => this.validate(doc)));
117
+ }
118
+ async findOne(filter = {}, options = {}) {
119
+ const doc = await invoke("plugin:mongoose|find_one", {
120
+ collection: this.name,
121
+ filter,
122
+ options
123
+ });
124
+ if (doc) {
125
+ return this.validate(doc);
126
+ }
127
+ return null;
128
+ }
110
129
  async create(doc) {
111
130
  const validatedDoc = await this.validate(doc);
112
131
  return await invoke("plugin:mongoose|create", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-mongoose",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Tauri plugin for MongoDB/Mongoose-like database operations",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",