Commit df3742b 1 parent 3605cc5 commit df3742b Copy full SHA for df3742b
File tree 1 file changed +45
-1
lines changed
1 file changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,51 @@ const usersRows = await db.select({
111
111
const usersWithPosts = aggregate ({ rows , pkey: ' id' , fields: { posts: ' post.id' }});
112
112
```
113
113
114
- ## Contributing
114
+ ### ` transform `
115
+
116
+ Transforms rows in a slightly more performant way than spreading the properties (in-place changes). Data-first and data-last overloads are available.
117
+
118
+ #### Data-first
119
+
120
+ You may choose to pass rows in the arguments to call ` transform ` in a stand-alone way.
121
+
122
+ ``` ts
123
+ import { db } from " ./db" ;
124
+ import { users } from " ./schema" ;
125
+ import { transform } from " drizzle-toolbelt" ;
126
+
127
+ const users = await db .select ({
128
+ id: users .id ,
129
+ name: users .name ,
130
+ }).from (users );
131
+
132
+ const usersWithNameUppercase = transform ({
133
+ rows ,
134
+ fields: {
135
+ name : (row ) => row .name .toUpperCase (),
136
+ }});
137
+ ```
138
+
139
+ #### Data-last
140
+
141
+ ``` ts
142
+ import { db } from " ./db" ;
143
+ import { users } from " ./schema" ;
144
+ import { transform } from " drizzle-toolbelt" ;
145
+
146
+ const users = await db .select ({
147
+ id: users .id ,
148
+ name: users .name ,
149
+ })
150
+ .from (users )
151
+ .then (transform ({
152
+ fields: {
153
+ name : (row ) => row .name .toUpperCase (),
154
+ }
155
+ }))
156
+ ```
157
+
158
+ ## Contributing
115
159
116
160
This project is open to contributions. Feel free to open an issue or a pull request.
117
161
You can’t perform that action at this time.
0 commit comments