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 +7 -3
- package/dist/define/Cursor.d.ts +2 -2
- package/dist/define/Cursor.js +2 -2
- package/dist/lib/Driver.js +1 -1
- package/package.json +1 -1
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()).
|
|
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}).
|
|
196
|
+
return User({id: this.userId}).first()
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
tags() {
|
package/dist/define/Cursor.d.ts
CHANGED
|
@@ -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
|
-
|
|
74
|
-
|
|
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>;
|
package/dist/define/Cursor.js
CHANGED
|
@@ -195,10 +195,10 @@ function addWhere(query, where) {
|
|
|
195
195
|
groupBy: groupBy.map(ExprData.create)
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
maybeFirst() {
|
|
199
199
|
return new SelectSingle({ ...this[QUERY], singleResult: true });
|
|
200
200
|
}
|
|
201
|
-
|
|
201
|
+
first() {
|
|
202
202
|
return new SelectSingle({
|
|
203
203
|
...this[QUERY],
|
|
204
204
|
singleResult: true,
|
package/dist/lib/Driver.js
CHANGED
|
@@ -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.
|
|
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);
|