@ai-lion/antdb
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

一个简单的基于 webpack 的模板

使用

 //antdb
    import AntDB from "@ai-lion/antdb";

    (async()=>{
        await AntDB.open({ dir: "" });

        let userModel = new UserModel();

    })();
    

定义model

import { AntDB, Schema, Length, IsNotEmpty, Column, IsInt, Max, Min } from "@ai-lion/antdb";
/**
 * Proxy
 */
export default class User extends Schema {
   constructor(data?) {
      super(data);
   }
   
   @Length(3, 16)
   @Column({ default: "" })
   username: string;

   @Column({ default: "" })
   password: string;

   @IsInt()
   @IsNotEmpty()
   @Column({ type: "number", default: 1 })
   status: 1 | 0;

}

export class UserModel extends AntDB<Proxy> {
   constructor() {
      super("proxy", Proxy);
   }
   async create(data: Proxy) {
      let exist = await this.findOne({ query: { host: data.host, port: data.port } });
      if (exist) {
         return exist;
      }
      return super.create(data);
   }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @ai-lion/antdb

Weekly Downloads

1

Version

2.0.2

License

MIT

Unpacked Size

2.75 MB

Total Files

6

Last publish

Collaborators

  • ai-lion