| 20 | }); |
| 21 | |
| 22 | async function run(client: InferFumaDB<typeof testDB>) { |
| 23 | expect(await client.version()).toBe("1.0.0"); |
| 24 | const orm = client.orm("1.0.0"); |
| 25 | const lines: string[] = []; |
| 26 | |
| 27 | lines.push("create initial records"); |
| 28 | await orm.createMany("users", [ |
| 29 | { |
| 30 | id: "fuma", |
| 31 | name: "fuma", |
| 32 | }, |
| 33 | { |
| 34 | id: "alfon", |
| 35 | name: "alfonsus", |
| 36 | }, |
| 37 | { |
| 38 | id: "joulev", |
| 39 | name: "joulev", |
| 40 | }, |
| 41 | ]); |
| 42 | await orm.createMany("posts", [ |
| 43 | { |
| 44 | id: "1", |
| 45 | authorId: "fuma", |
| 46 | content: "hello world", |
| 47 | }, |
| 48 | { |
| 49 | id: "2", |
| 50 | authorId: "joulev", |
| 51 | relyTo: "1", |
| 52 | attachmentUrl: "attachment-1", |
| 53 | }, |
| 54 | { |
| 55 | id: "3", |
| 56 | authorId: "alfon", |
| 57 | content: "hehe", |
| 58 | }, |
| 59 | ]); |
| 60 | await orm.createMany("attachments", [ |
| 61 | { |
| 62 | id: "1", |
| 63 | url: "attachment-1", |
| 64 | data: new Uint8Array([1, 2, 3, 4]), |
| 65 | }, |
| 66 | ]); |
| 67 | |
| 68 | lines.push("get initial records"); |
| 69 | lines.push( |
| 70 | inspect(await orm.findMany("users", { orderBy: ["id", "asc"] }), { |
| 71 | depth: null, |
| 72 | sorted: true, |
| 73 | }) |
| 74 | ); |
| 75 | lines.push( |
| 76 | inspect(await orm.findMany("posts"), { depth: null, sorted: true }) |
| 77 | ); |
| 78 | lines.push( |
| 79 | inspect(await orm.findMany("attachments"), { depth: null, sorted: true }) |