@ragestudio/scylla-odm 0.16.0 → 0.18.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.
package/model/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { mapping } from "../driver/lib/mapping/index.js";
2
2
  import { Schema } from "../schema/index.js";
3
3
  import export_default from "../operations/tableExists.js";
4
4
  import syncOP from "../operations/sync.js";
5
- import { Doc, InferDoc, Query, QueryOptions } from "../types.js";
5
+ import { Doc, FindQueryOptions, InferDoc, Query } from "../types.js";
6
6
  import { Client } from "../client.js";
7
7
 
8
8
  //#region src/model/index.d.ts
@@ -15,16 +15,16 @@ declare class Model<TSchema extends Schema<any> = Schema<any>, TDoc = InferDoc<T
15
15
  create: (data: Partial<TDoc>) => Doc<TDoc>;
16
16
  obj: (data: Partial<TDoc>) => Doc<TDoc>;
17
17
  find: {
18
- (query: Query<TDoc>, options: QueryOptions & {
18
+ (query: Query<TDoc>, options: FindQueryOptions<TDoc> & {
19
19
  raw: true;
20
20
  }): Promise<TDoc[]>;
21
- (query?: Query<TDoc>, options?: QueryOptions): Promise<Doc<TDoc>[]>;
21
+ (query?: Query<TDoc>, options?: FindQueryOptions<TDoc>): Promise<Doc<TDoc>[]>;
22
22
  };
23
23
  findOne: {
24
- (query: Query<TDoc>, options: QueryOptions & {
24
+ (query: Query<TDoc>, options: FindQueryOptions<TDoc> & {
25
25
  raw: true;
26
26
  }): Promise<TDoc | null>;
27
- (query?: Query<TDoc>, options?: QueryOptions): Promise<Doc<TDoc> | null>;
27
+ (query?: Query<TDoc>, options?: FindQueryOptions<TDoc>): Promise<Doc<TDoc> | null>;
28
28
  };
29
29
  update: (query: Query<TDoc>) => Promise<Doc<TDoc>>;
30
30
  delete: (query: Query<TDoc>) => Promise<mapping.Result>;
@@ -1,7 +1,7 @@
1
1
  import { Model } from "../model/index.js";
2
- import { Query, QueryOptions } from "../types.js";
2
+ import { FindQueryOptions, Query } from "../types.js";
3
3
 
4
4
  //#region src/operations/find.d.ts
5
- declare function findOP<TDoc>(this: Model<any, TDoc>, query?: Query<TDoc>, options?: QueryOptions): Promise<any[]>;
5
+ declare function findOP<TDoc>(this: Model<any, TDoc>, query?: Query<TDoc>, options?: FindQueryOptions<TDoc>): Promise<any[]>;
6
6
  //#endregion
7
7
  export { findOP as default };
@@ -1 +1 @@
1
- import e from"../utils/queryParser.js";async function t(t={},n){let{$limit:r,$orderby:i,...a}=t,o=e(this,a),s={};if(r!==void 0){if(typeof r!=`number`||r<=0)throw TypeError(`{$limit} operator must be a number greater than 0`);s.limit=r}return i!==void 0&&(s.orderBy=i),this.client.executeWithRetry(async()=>{let e=(await this.mapper.find(o,s)).toArray();return n?.raw===!0?e:e.map(e=>this._wrap(e))},`find on ${this.name}`)}export{t as default};
1
+ import e from"../utils/queryParser.js";async function t(t={},n){return t=e(this,t),this.client.executeWithRetry(async()=>{let e=(await this.mapper.find(t,n)).toArray();return n?.raw===!0?e:e.map(e=>this._wrap(e))},`find on ${this.name}`)}export{t as default};
@@ -1,7 +1,7 @@
1
1
  import { Model } from "../model/index.js";
2
- import { QueryOptions } from "../types.js";
2
+ import { FindQueryOptions, Query } from "../types.js";
3
3
 
4
4
  //#region src/operations/findOne.d.ts
5
- declare function findOneOP<TDoc>(this: Model<any, TDoc>, query: any, options?: QueryOptions): Promise<any>;
5
+ declare function findOneOP<TDoc>(this: Model<any, TDoc>, query?: Query<TDoc>, options?: FindQueryOptions<TDoc>): Promise<any>;
6
6
  //#endregion
7
7
  export { findOneOP as default };
@@ -1 +1 @@
1
- import e from"../utils/queryParser.js";async function t(t,n){return t=e(this,t),this.client.executeWithRetry(async()=>{let e=await this.mapper.get(t);return e?(e=this._wrap(e),n?.raw===!0?e.toRaw():e):null},`findOne on ${this.name}`)}export{t as default};
1
+ import e from"../utils/queryParser.js";async function t(t={},n){return t=e(this,t),this.client.executeWithRetry(async()=>{let e=await this.mapper.get(t,n);return e?n?.raw===!0?e:this._wrap(e):null},`findOne on ${this.name}`)}export{t as default};
@@ -1 +1 @@
1
- import e from"../utils/fillDefaults.js";async function t(t){return t=e(this.schema,t),t.__v!==void 0&&(Number.isNaN(t.__v)?t.__v=0:t.__v+=1),this.client.executeWithRetry(async()=>(await this.mapper.update(t),this._wrap(t)),`update on ${this.name}`)}export{t as default};
1
+ import e from"../utils/fillDefaults.js";import t from"../utils/queryParser.js";async function n(n){return n=e(this.schema,n),n=t(this,n),n.__v!==void 0&&(Number.isNaN(n.__v)?n.__v=0:n.__v+=1),this.client.executeWithRetry(async()=>(await this.mapper.update(n),this._wrap(n)),`update on ${this.name}`)}export{n as default};
package/package.js CHANGED
@@ -1 +1 @@
1
- var e=`0.16.0`,t=`An ODM for ScyllaDB/Cassandra`;export{t as description,e as version};
1
+ var e=`0.18.0`,t=`An ODM for ScyllaDB/Cassandra`;export{t as description,e as version};
package/package.json CHANGED
@@ -1,12 +1,24 @@
1
1
  {
2
2
  "name": "@ragestudio/scylla-odm",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "An ODM for ScyllaDB/Cassandra",
5
+ "license": "MIT",
6
+ "author": "RageStudio",
5
7
  "repository": {
6
8
  "url": "https://git.ragestudio.net/ragestudio/scylla-odm"
7
9
  },
8
- "license": "MIT",
9
- "author": "RageStudio",
10
+ "bugs": {
11
+ "url": "https://git.ragestudio.net/ragestudio/scylla-odm/issues"
12
+ },
13
+ "keywords": [
14
+ "scylladb",
15
+ "cassandra",
16
+ "odm",
17
+ "database",
18
+ "driver",
19
+ "mapper",
20
+ "typescript"
21
+ ],
10
22
  "type": "module",
11
23
  "types": "./index.d.ts",
12
24
  "main": "./index.js",
package/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { mapping } from "./driver/lib/mapping/index.js";
1
2
  import { ClientOptions } from "./driver/index.js";
2
3
  import { Schema } from "./schema/index.js";
3
4
  import { Document } from "./document/index.js";
@@ -44,29 +45,27 @@ declare enum ColumnTypes {
44
45
  Varchar = "varchar",
45
46
  Varint = "varint"
46
47
  }
47
- type QueryOperators<TValue> = {
48
- $eq?: TValue;
49
- $ne?: TValue;
50
- $in?: TValue[];
51
- $gt?: TValue;
52
- $gte?: TValue;
53
- $lt?: TValue;
54
- $lte?: TValue;
55
- };
56
48
  type TableKeys = (string | TableKeys)[];
57
49
  interface Column<T> {
58
50
  type?: ColumnTypes | string;
59
51
  required?: boolean;
60
52
  }
61
- type Query<TDoc> = { [K in keyof TDoc]?: TDoc[K] | QueryOperators<TDoc[K]> } & {
62
- $and?: Query<TDoc>[];
63
- $limit?: number;
64
- $orderby?: { [K in keyof TDoc]?: "asc" | "desc" };
53
+ type QueryOperators<T> = {
54
+ $eq?: T;
55
+ $ne?: T;
56
+ $in?: T[];
57
+ $gt?: T;
58
+ $gte?: T;
59
+ $lt?: T;
60
+ $lte?: T;
61
+ $and?: Query<T>[];
65
62
  };
66
- type QueryOptions = {
63
+ type Query<T> = { [K in keyof T]?: T[K] | QueryOperators<T[K]> };
64
+ type FindQueryOptions<T> = {
67
65
  raw?: boolean;
68
- };
66
+ orderBy?: { [K in keyof T]?: "asc" | "desc" };
67
+ } & mapping.FindDocInfo;
69
68
  type Doc<TDoc = any> = Document<TDoc> & TDoc;
70
69
  type InferDoc<S> = S extends Schema<infer T> ? { [K in keyof T as K extends `$${string}` ? never : K]: T[K] extends Column<infer U> ? U : T[K] } : any;
71
70
  //#endregion
72
- export { ClientConfig, Column, ColumnTypes, Doc, InferDoc, Query, QueryOperators, QueryOptions, TableKeys };
71
+ export { ClientConfig, Column, ColumnTypes, Doc, FindQueryOptions, InferDoc, Query, QueryOperators, TableKeys };