Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
2b028891
Unverified
Commit
2b028891
authored
Nov 16, 2023
by
Tom Ballinger
Committed by
GitHub
Nov 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples: Upgrade Convex example to convex@1.2.1 (#54910)
Co-authored-by:
Lee Robinson
<
me@leerob.io
>
parent
6d9ce62f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
29 deletions
+33
-29
README.md
examples/convex/convex/README.md
+16
-13
api.d.ts
examples/convex/convex/_generated/api.d.ts
+1
-1
api.js
examples/convex/convex/_generated/api.js
+1
-1
dataModel.d.ts
examples/convex/convex/_generated/dataModel.d.ts
+1
-1
server.d.ts
examples/convex/convex/_generated/server.d.ts
+9
-9
server.js
examples/convex/convex/_generated/server.js
+1
-1
tsconfig.json
examples/convex/convex/tsconfig.json
+2
-1
package.json
examples/convex/package.json
+2
-2
No files found.
examples/convex/convex/README.md
View file @
2b028891
...
...
@@ -5,7 +5,7 @@ https://docs.convex.dev/using/writing-convex-functions for more.
A query function that takes two arguments looks like:
```
javascript
```
ts
// functions.js
import
{
query
}
from
'./_generated/server'
import
{
v
}
from
'convex/values'
...
...
@@ -18,10 +18,13 @@ export const myQueryFunction = query({
},
// Function implementation.
hander
:
async
(
{
db
},
{
first
,
second
}
)
=>
{
hander
:
async
(
ctx
,
args
)
=>
{
// Read the database as many times as you need here.
// See https://docs.convex.dev/database/reading-data.
const
documents
=
await
db
.
query
(
'tablename'
).
collect
()
const
documents
=
await
ctx
.
db
.
query
(
'tablename'
).
collect
()
// Arguments passed from the client are properties of the args object.
console
.
log
(
args
.
first
,
args
.
second
)
// Write arbitrary JavaScript here: filter, aggregate, build derived data,
// remove non-public properties, or create new objects.
...
...
@@ -32,7 +35,7 @@ export const myQueryFunction = query({
Using this query function in a React component looks like:
```
javascript
```
ts
const
data
=
useQuery
(
api
.
functions
.
myQueryFunction
,
{
first
:
10
,
second
:
'hello'
,
...
...
@@ -41,7 +44,7 @@ const data = useQuery(api.functions.myQueryFunction, {
A mutation function looks like:
```
javascript
```
ts
// functions.js
import
{
mutation
}
from
'./_generated/server'
import
{
v
}
from
'convex/values'
...
...
@@ -54,22 +57,22 @@ export const myMutationFunction = mutation({
},
// Function implementation.
hander
:
async
(
{
db
},
{
first
,
second
}
)
=>
{
hander
:
async
(
ctx
,
args
)
=>
{
// Insert or modify documents in the database here.
// Mutations can also read from the database like queries.
// See https://docs.convex.dev/database/writing-data.
const
message
=
{
body
:
first
,
author
:
second
}
const
id
=
await
db
.
insert
(
'messages'
,
message
)
const
message
=
{
body
:
args
.
first
,
author
:
args
.
second
}
const
id
=
await
ctx
.
db
.
insert
(
'messages'
,
message
)
// Optionally, return a value from your mutation.
return
await
db
.
get
(
id
)
return
await
ctx
.
db
.
get
(
id
)
},
})
```
Using this mutation function in a React component looks like:
```
javascript
```
ts
const
mutation
=
useMutation
(
api
.
functions
.
myMutationFunction
)
function
handleButtonPress
()
{
// fire and forget, the most common way to use mutations
...
...
@@ -82,6 +85,6 @@ function handleButtonPress() {
}
```
The Convex CLI is your friend. See everything it can do by runn
ing
`npx convex -h`
in your project root directory. To learn more, launch the docs
with
`npx convex docs`
.
Use the Convex CLI to push your functions to a deployment. See everyth
ing
the Convex CLI can do by running
`npx convex -h`
in your project root
directory. To learn more, launch the docs
with
`npx convex docs`
.
examples/convex/convex/_generated/api.d.ts
View file @
2b028891
...
...
@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@
0.19.0
.
* Generated by convex@
1.2.1
.
* To regenerate, run `npx convex dev`.
* @module
*/
...
...
examples/convex/convex/_generated/api.js
View file @
2b028891
...
...
@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@
0.19.0
.
* Generated by convex@
1.2.1
.
* To regenerate, run `npx convex dev`.
* @module
*/
...
...
examples/convex/convex/_generated/dataModel.d.ts
View file @
2b028891
...
...
@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@
0.19.0
.
* Generated by convex@
1.2.1
.
* To regenerate, run `npx convex dev`.
* @module
*/
...
...
examples/convex/convex/_generated/server.d.ts
View file @
2b028891
...
...
@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@
0.19.0
.
* Generated by convex@
1.2.1
.
* To regenerate, run `npx convex dev`.
* @module
*/
...
...
@@ -14,11 +14,11 @@ import {
HttpActionBuilder
,
MutationBuilder
,
QueryBuilder
,
ActionCtx
as
GenericActionCtx
,
MutationCtx
as
GenericMutationCtx
,
QueryCtx
as
GenericQueryCtx
,
DatabaseReader
as
GenericDatabaseReader
,
DatabaseWriter
as
GenericDatabaseWriter
,
GenericActionCtx
,
GenericMutationCtx
,
GenericQueryCtx
,
GenericDatabaseReader
,
GenericDatabaseWriter
,
}
from
"convex/server"
;
import
type
{
DataModel
}
from
"./dataModel.js"
;
...
...
@@ -73,7 +73,7 @@ export declare const internalMutation: MutationBuilder<DataModel, "internal">;
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
*/
export
declare
const
action
:
ActionBuilder
<
"public"
>
;
export
declare
const
action
:
ActionBuilder
<
DataModel
,
"public"
>
;
/**
* Define an action that is only accessible from other Convex functions (but not from the client).
...
...
@@ -81,7 +81,7 @@ export declare const action: ActionBuilder<"public">;
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
*/
export
declare
const
internalAction
:
ActionBuilder
<
"internal"
>
;
export
declare
const
internalAction
:
ActionBuilder
<
DataModel
,
"internal"
>
;
/**
* Define an HTTP action.
...
...
@@ -120,7 +120,7 @@ export type MutationCtx = GenericMutationCtx<DataModel>;
* The action context is passed as the first argument to any Convex action
* function run on the server.
*/
export
type
ActionCtx
=
GenericActionCtx
;
export
type
ActionCtx
=
GenericActionCtx
<
DataModel
>
;
/**
* An interface to read from the database within Convex query functions.
...
...
examples/convex/convex/_generated/server.js
View file @
2b028891
...
...
@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@
0.19.0
.
* Generated by convex@
1.2.1
.
* To regenerate, run `npx convex dev`.
* @module
*/
...
...
examples/convex/convex/tsconfig.json
View file @
2b028891
...
...
@@ -16,7 +16,8 @@
"module"
:
"ESNext"
,
"moduleResolution"
:
"Node"
,
"isolatedModules"
:
true
,
"noEmit"
:
true
"noEmit"
:
true
,
"skipLibCheck"
:
true
},
"include"
:
[
"./**/*"
],
"exclude"
:
[
"./_generated"
]
...
...
examples/convex/package.json
View file @
2b028891
...
...
@@ -10,7 +10,7 @@
"start"
:
"next start"
},
"dependencies"
:
{
"convex"
:
"~
0.19.0
"
,
"convex"
:
"~
1.2.1
"
,
"next"
:
"latest"
,
"react"
:
"^18.2.0"
,
"react-dom"
:
"^18.2.0"
...
...
@@ -20,6 +20,6 @@
"@types/react-dom"
:
"18.0.11"
,
"@types/react"
:
"18.2.8"
,
"npm-run-all"
:
"^4.1.5"
,
"typescript"
:
"^
4.9.5
"
"typescript"
:
"^
5.0.3
"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment