當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript IConnection.query方法代碼示例

本文整理匯總了TypeScript中mysql.IConnection.query方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IConnection.query方法的具體用法?TypeScript IConnection.query怎麽用?TypeScript IConnection.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mysql.IConnection的用法示例。


在下文中一共展示了IConnection.query方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例2: reject

    return new Promise<T[]>((resolve, reject) => {
      this.debug(query, args);
      this.connection.query(query, args, (err: any, rows: T[]) => {
        if (err) {
          reject(new SqlException(err));
          return;
        }

        resolve(rows);
      });
    });
開發者ID:paullessing,項目名稱:splitting-bills,代碼行數:11,代碼來源:database.service.ts

示例3: 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

示例4: getTables

 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

示例5: describe

 describe(table:string, cb?) {
     this.db.query('DESCRIBE ??', [table], cb);
 }
開發者ID:emilioastarita,項目名稱:typed-rows,代碼行數:3,代碼來源:Information.ts

示例6: generateModels

if (program.all) {
    // Get list of tables
    let query = squel
        .select()
        .field('table_name')
        .from('information_schema.tables')
        .where('table_schema=?',config.db.database)
        .toString();

    connection.query(query, (err, result) => {
        if (err){
            console.log('Error getting tables');
            process.exit(1);
        }

        let tables = [];

        for(let i=0;i<result.length;i++){
            tables.push(result[i].table_name);
        }

        generateModels(tables);
    });
} else {
    generateModels(program.tables.split(','));
}

function generateModels(tables){
    for(let i=0;i<tables.length;i++){
        generateModel(tables[i]);
    }
}
開發者ID:kylehengst,項目名稱:NTMMG,代碼行數:32,代碼來源:app.ts


注:本文中的mysql.IConnection.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。