rado 0.2.17 → 0.2.18

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/README.md CHANGED
@@ -89,7 +89,7 @@ Post().select({
89
89
  ...Post,
90
90
  author: Post.author().select(User.username),
91
91
  tags: Post.tags().select({
92
- count: pt({tagId: Tag.id}).select(count()).sure(),
92
+ count: pt({tagId: Tag.id}).select(count()).first(),
93
93
  name: Tag.name
94
94
  })
95
95
  })
@@ -112,7 +112,11 @@ Person().select({
112
112
  name: Person.firstName.concat(' ').concat(Person.lastName),
113
113
  isMario: Person.firstName.is('Mario'),
114
114
  isActor: Person.id.isIn(Actor().select(Actor.personId)),
115
- email: iif(Person.email.isNotNull(), Person.email, 'its.me@mario')
115
+ email: iif(Person.email.isNotNull(), Person.email, 'its.me@mario'),
116
+ twitterHandle: Person.socialMedia
117
+ .filter(media => media.type.is('twitter'))
118
+ .map(media => media.handle)
119
+ .maybeFirst()
116
120
  })
117
121
  ```
118
122
 
@@ -189,7 +193,7 @@ const Post = table({
189
193
  content = column.string
190
194
 
191
195
  author() {
192
- return User({id: this.userId}).sure()
196
+ return User({id: this.userId}).first()
193
197
  }
194
198
 
195
199
  tags() {
@@ -70,8 +70,8 @@ export declare namespace Cursor {
70
70
  count(): SelectSingle<number>;
71
71
  orderBy(...orderBy: Array<Expr<any> | OrderBy>): SelectMultiple<Row>;
72
72
  groupBy(...groupBy: Array<Expr<any>>): SelectMultiple<Row>;
73
- first(): SelectSingle<Row | undefined>;
74
- sure(): SelectSingle<Row>;
73
+ maybeFirst(): SelectSingle<Row | undefined>;
74
+ first(): SelectSingle<Row>;
75
75
  where(...where: Array<EV<boolean>>): SelectMultiple<Row>;
76
76
  take(limit: number | undefined): SelectMultiple<Row>;
77
77
  skip(offset: number | undefined): SelectMultiple<Row>;
@@ -195,10 +195,10 @@ function addWhere(query, where) {
195
195
  groupBy: groupBy.map(ExprData.create)
196
196
  });
197
197
  }
198
- first() {
198
+ maybeFirst() {
199
199
  return new SelectSingle({ ...this[QUERY], singleResult: true });
200
200
  }
201
- sure() {
201
+ first() {
202
202
  return new SelectSingle({
203
203
  ...this[QUERY],
204
204
  singleResult: true,
@@ -46,7 +46,7 @@ var DriverBase = class {
46
46
  get(...args) {
47
47
  const [input, ...rest] = args;
48
48
  if (input instanceof Cursor.SelectMultiple)
49
- return this.executeQuery(input.first()[Cursor.Query]);
49
+ return this.executeQuery(input.maybeFirst()[Cursor.Query]);
50
50
  if (input instanceof Cursor)
51
51
  return this.executeQuery(input[Cursor.Query]);
52
52
  return this.executeTemplate("row", input, ...rest);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rado",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",