11import 'reflect-metadata'
22
3- import { Column , Func , Model } from '@devup-api/model'
4- import {
5- createRevision ,
6- createSqliteConnection ,
7- migrate ,
8- } from '@devup-sql/sqlite'
3+ import { Column , DevupModel , Func , Model } from '@devup-api/model'
4+ import { createSqliteConnection } from '@devup-sql/sqlite'
95describe ( 'sqlite' , async ( ) => {
106 const pool = await createSqliteConnection ( {
117 url : 'sqlite::memory:' ,
@@ -41,7 +37,7 @@ describe('sqlite', async () => {
4137 } )
4238 describe ( 'model' , ( ) => {
4339 @Model ( )
44- class User {
40+ class User extends DevupModel {
4541 @Column ( {
4642 name : 'id' ,
4743 primaryKey : true ,
@@ -67,20 +63,34 @@ describe('sqlite', async () => {
6763 createdAt : Date
6864 }
6965 it ( 'test' , async ( ) => {
70- const revisions = await loadRevisions ( )
71- // create next revision from revision
72- const nextRevisions = await createRevision ( revisions )
73- const currentRevision = await currentRevision ( pool )
74- // apply sql script
75- const sql = getSqlFromRevision ( revisions [ 0 ] )
76- await migrate ( pool , nextRevisions )
66+ // get current revision
67+ const currentRevision = await pool . getCurrentRevision ( )
68+ // create revision
69+ const nextRevision = await pool . createRevision ( )
70+ // migrate to next revision
71+ await pool . migrate ( nextRevision )
7772
78- const user = new User ( )
79- user . username = 'devup'
80- await user . save ( )
73+ // const user = new User()
74+ // user.username = 'devup'
75+ // await user.save()
8176
82- const user = await User . findById ( 1 )
83- expect ( user ?. username ) . toEqual ( 'devup' )
77+ // const user = await User.findById(1)
78+ // expect(user?.username).toEqual('devup')
79+
80+ const user = await User . findOne ( {
81+ filter : { } ,
82+ } )
83+
84+ const users = await User . findAll ( {
85+ filter : {
86+ username : 'devup' ,
87+ } ,
88+ limit : 10 ,
89+ offset : 0 ,
90+ order : {
91+ id : 'ASC' ,
92+ } ,
93+ } )
8494
8595 expect ( 0 ) . toEqual ( 0 )
8696 } )
0 commit comments