• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript mysql.IConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中mysql.IConnection的典型用法代码示例。如果您正苦于以下问题:TypeScript IConnection类的具体用法?TypeScript IConnection怎么用?TypeScript IConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了IConnection类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe("Book copy dao", function () {

    let conn: IConnection;
    before(function (done) {
        DbConnection.initConnection("development");
        conn = DbConnection.getConnection();
        conn.query("CALL reset_db_for_test()", function (err) {
            if (err) {
                console.log(err);
                throw err;
            }
            done();
            //
        });
    });


    it("should find 240 copies when find with no argument", function (done) {
        BookCopy.dao.find({}, function (err, bookcopies) {
            if (err) {
                throw err;
            }
            bookcopies.should.have.length(240);
            done();
        });
    });
    /*
    it("update with isbn argument should update 10 copies", function (done) {
        let bookcopy = new BookCopy();
        bookcopy.status = "BORROWED";
        BookCopy.dao.update(bookcopy, {}, function (err, results) {
            if (err) {
                throw err;
            }
            console.log(results);
            results.affectedRows.should.equal(1);
            done();
        });
    });*/

});
开发者ID:JohanBaskovec,项目名称:libraryBackEnd,代码行数:41,代码来源:book-copy-dao.spec.ts


示例2: describe

describe("Book API: UPDATE", function () {
    let url = "http://localhost:5000";
    let conn: IConnection;
    before(function (done) {
        DbConnection.initConnection("development");
        conn = DbConnection.getConnection();
        conn.query("CALL reset_db_for_test()", function (err) {
            if (err) {
                console.log(err);
                throw err;
            }
            done();
        });
    });

    it("should save correctly formed book", function (done) {


        let book = {
            title: "TESTTEST", author: "TESTTEST", isbn: "isbn1",
            pages: 5646, year: 2013, editorid: 1
        };
        request(url)
            .put("/api/books")
            .send(book)
            .end(function (err, res) {
                if (err) {
                    throw err;
                }
                res.status.should.equal(200);

                request(url)
                    .get("/api/books?isbn=isbn1")
                    .end(function (err, res) {
                        if (err) {
                            throw err;
                        }
                        res.status.should.equal(200);


                        done();
                    });
            });
    });
    it("should not save book with year in the future", function (done) {


        let book = {
            title: "TESTTEST", author: "TESTTEST", isbn: "isbn1",
            pages: 5646, year: 2123, editorid: 1
        };
        request(url)
            .put("/api/books")
            .send(book)
            .end(function (err, res) {
                if (err) {
                    throw err;
                }
                res.status.should.equal(400);
                done();

            });
    });

    it("should not save book with editorid absent from database", function (done) {

        let book = {
            title: "test1", author: "test1", isbn: "isbnTEST2",
            pages: 5646, year: 2123, editorid: 99999
        };
        request(url)
            .put("/api/books")
            .send(book)
            .end(function (err, res) {
                if (err) {
                    throw err;
                }
                res.status.should.equal(400);

                done();
            });
    });
});
开发者ID:JohanBaskovec,项目名称:libraryBackEnd,代码行数:83,代码来源:book-rest.spec.ts


示例3: reject

 .then((result: T) => new Promise<T>((resolve, reject) => {
   this.connection.commit(err => {
     if (err) {
       reject(err);
     } else {
       resolve(result);
     }
   });
 }))
开发者ID:paullessing,项目名称:splitting-bills,代码行数:9,代码来源:database.service.ts


示例4:

 }, (err, outputs) => {
     const header = this.getHeaderFile();
     fs.write(fd, header + outputs.join("\n\n") + "\n", (err) => {
         if (err) {
             console.error(err.message);
             process.exit(1);
         }
     });
     connection.end();
 });
开发者ID:emilioastarita,项目名称:typed-rows,代码行数:10,代码来源:TypedRows.ts


示例5: before

 before(function (done) {
     DbConnection.initConnection("development");
     conn = DbConnection.getConnection();
     conn.query("CALL reset_db_for_test()", function (err) {
         if (err) {
             console.log(err);
             throw err;
         }
         done();
     });
 });
开发者ID:JohanBaskovec,项目名称:libraryBackEnd,代码行数:11,代码来源:book-rest.spec.ts


示例6: generateModel

function generateModel(tableName){
    // Get table detail
    connection.query('DESC '+tableName, (err, result) => {
        if (err){
            console.log('Error getting structure of table '+tableName);
        }

        let parsedName = parseTableName(tableName);

        let output = "";

        if (config.baseModel) {
            output += "import {BaseModel as "+config.baseModel.className+"} from \"./"+config.baseModel.fileName+"\";\r\n";
            output += "import {IModelValidationRule} from \"./"+config.baseModel.fileName+"\";\r\n";

            output += "\r\n";
        }

        output += "export interface I"+parsedName+" {\r\n";

        for(let i=0;i<result.length;i++){
            output += "    "+result[i].Field+((result[i].Null === 'YES')?"?":"")+": "+getTSType(result[i].Type)+";\r\n";
        }

        output += "}\r\n";

        output += "\r\n";

        output += "export class "+parsedName+" "+((config.baseModel)?"extends "+config.baseModel.className:"")+" { \r\n";

        output += "    public static tableName: string = \"" + tableName+"\";\r\n";
        output += "\r\n";
        output += "    public safe: String[] = [];\r\n";
        output += "\r\n";
        output += "    public rules: IModelValidationRule[] = [];\r\n"; // @todo: If not using base model, this will yeld error
        output += "\r\n";
        output += "    public attr: I" + parsedName + " = {\r\n";

        for(let i=0;i<result.length;i++){
            output += "        "+result[i].Field+": undefined,\r\n";
        }

        output += "    };\r\n";

        output += "}\r\n";

        fs.writeFile(program.output+tableName+'.ts',output,(err) => {
            if (err) throw err;

            console.log('Model for table '+tableName+' generated!');
        });
    });
}
开发者ID:kylehengst,项目名称:NTMMG,代码行数:53,代码来源:app.ts


示例7: cb

 getTables(cb:(error:any, tables?:string[]) => void) {
     this.db.query('show tables', (err, result, fields) => {
         if (err) {
             return cb(err)
         }
         let field:string = fields[0].name;
         let tables:string[] = [];
         for (const info of result) {
             let table = info[field];
             tables.push(table);
         }
         cb(null, tables);
     });
 }
开发者ID:emilioastarita,项目名称:typed-rows,代码行数:14,代码来源:Information.ts


示例8: initConnection

    static initConnection(env: string) {
        switch (env) {
            case 'development':

                this.dbConnection = mysql.createConnection(credentials.development.connection);
                break;
            case 'production':
                this.dbConnection = mysql.createConnection(credentials.production.connection);
                break;
            default:
                throw new Error('Unknown execution environment: ' + env);
        }
        this.dbConnection.connect();
    }
开发者ID:JohanBaskovec,项目名称:libraryBackEnd,代码行数:14,代码来源:database.ts



注:本文中的mysql.IConnection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript mysql2Types.IConnection类代码示例发布时间:2022-05-25
下一篇:
TypeScript mysql.Connection类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap