This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ curl http://localhost:8080/dev/posts | |
| { | |
| "next_page": "http://localhost:8080/dev/posts?cursor=eyJheGVzIjpbeyJrZXkiOnsiZmllbGROYW1lIjoiaWQiLCJhc2NlbmRpbmciOnRydWV9LCJ2YWx1ZSI6ImMyNzMwODA3LTVjZWYtNDQ0MC1hNzk2LWVjNjIxNjcxMjZkYyJ9XSwiZm9yd2FyZCI6dHJ1ZSwiaW5jbHVzaXZlIjpmYWxzZX0%3D", | |
| "prev_page": "http://localhost:8080/dev/posts?cursor=eyJheGVzIjpbeyJrZXkiOnsiZmllbGROYW1lIjoiaWQiLCJhc2NlbmRpbmciOnRydWV9LCJ2YWx1ZSI6IjE5YTQzOTU3LWVmN2YtNGViZC04MDk2LTJkN2UzNzQ5NGUyYSJ9XSwiZm9yd2FyZCI6ZmFsc2UsImluY2x1c2l2ZSI6ZmFsc2V9", | |
| "results": [ | |
| { | |
| "id": "19a43957-ef7f-4ebd-8096-2d7e37494e2a", | |
| "title": "my first post", | |
| "markdown": "Here iss our first post" | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ curl -d '{"title": "my first post", "markdown": "Here is our first post"}' http://localhost:8080/dev/posts | |
| { | |
| "id": "19a43957-ef7f-4ebd-8096-2d7e37494e2a", | |
| "title": "my first post", | |
| "markdown": "Here is our first post" | |
| } | |
| $ curl -d '{"title": "my second post", "markdown": "Here is our second post"}' http://localhost:8080/dev/posts | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ npm install # install remix' npm packages | |
| $ cp .env.example .env # uses the example environment variables, good enough for testing | |
| $ npm run dev # runs the Remix development server, and also starts ChiselStrike |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Post } from "../models/Post.ts"; | |
| export default Post.crud(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ChiselEntity } from "@chiselstrike/api"; | |
| export class Post extends ChiselEntity { | |
| title: string; | |
| markdown: string; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[op] | |
| fn op_chisel_relational_query_create( | |
| op_state: &mut OpState, | |
| op_chain: QueryOpChain, | |
| context: ChiselRequestContext, | |
| ) -> Result<ResourceId> { | |
| let query_plan = QueryPlan::from_op_chain( | |
| &RequestContext::new( | |
| current_policies(op_state), | |
| current_type_system(op_state), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Client } from "../models/Client"; | |
| import { Entry } from "../models/Entry"; | |
| import { Space } from "../models/Space"; | |
| type UserValue = { | |
| op: 'del'; | |
| key: string; | |
| } | { | |
| op: 'put'; | |
| key: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const todos = useSubscribe(rep, async tx => { | |
| return await tx.scan({prefix: 'todo/'}).toArray(); | |
| }); | |
| return ( | |
| <ul> | |
| {todos.map(todo => ( | |
| <li key={todo.id}>{todo.text}</li> | |
| ))} | |
| </ul> | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Replicache} from "replicache"; | |
| const rep = new Replicache({ | |
| pushURL: '/api/replicache-push', | |
| pullURL: '/api/replicache-pull', | |
| ... | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| f: | |
| xor eax, eax ; exclusive-or to return register | |
| ret |