Last active
August 29, 2015 14:09
-
-
Save kjlape/792592c7782e451b8802 to your computer and use it in GitHub Desktop.
Wrap mssql npm package for meteor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NodeSql = Npm.require 'mssql' | |
| Connection = NodeSql.Connection | |
| Request = NodeSql.Request | |
| Transaction = NodeSql.Transaction | |
| wrapProtoFunc = (klass, name) -> | |
| Meteor.wrapAsync klass.prototype[name] | |
| class wRequest extends Request | |
| _acquire: wrapProtoFunc Request '_acquire' | |
| batch: wrapProtoFunc Request 'batch' | |
| bulk: wrapProtoFunc Request 'bulk' | |
| query: wrapProtoFunc Request 'query' | |
| execute: wrapProtoFunc Request 'execute' | |
| class wTransaction extends Transaction | |
| begin: wrapProtoFunc Transaction, 'begin' | |
| commit: wrapProtoFunc Transaction, 'commit' | |
| queue: wrapProtoFunc Transaction, 'queue' | |
| rollback: wrapProtoFunc Transaction, 'rollback' | |
| request: -> | |
| new wRequest @ | |
| class wPreparedStatement extends PreparedStatement | |
| prepare: wrapProtoFunc Transaction, 'prepare' | |
| queue: wrapProtoFunc Transaction, 'queue' | |
| unprepare: wrapProtoFunc Transaction, 'unprepare' | |
| # The original function returns a Request object. | |
| # It is not yet clear whether this behavior needs | |
| # to be retained. | |
| execute: wrapProtoFunc Transaction, 'execute' | |
| class wConnection extends Connection | |
| constructor: Meteor.wrapAsync Connection | |
| connect: wrapProtoFunc Connection 'connect' | |
| close: wrapProtoFunc Connection 'close' | |
| request: -> | |
| new wRequest @ | |
| transaction: -> | |
| new wTransaction @ | |
| @MsSql = | |
| connect: Meteor.wrapAsync NodeSql.connect | |
| close: Meteor.wrapAsync NodeSql.close | |
| Connection: wConnection | |
| Request: wRequest | |
| Transaction: wTransaction | |
| PreparedStatement: wPreparedStatement | |
| Table: NodeSql.Table | |
| ConnectionError: NodeSql.ConnectionError | |
| TransactionError: NodeSql.TransactionError | |
| RequestError: NodeSql.RequestError | |
| PreparedStatementError: NodeSql.PreparedStatementError | |
| ISOLATION_LEVEL: NodeSql.ISOLATION_LEVEL | |
| DRIVERS: NodeSql.DRIVERS | |
| TYPES: NodeSql.TYPES | |
| MAX: NodeSql.MAX | |
| map: NodeSql.map | |
| fix: NodeSql.fix | |
| for key, value of NodeSql.TYPES | |
| MsSql[key] = value | |
| MsSql[key.toUpperCase()] = value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Package.describe({ | |
| name: 'pingortle:mssql', | |
| summary: ' /* Fill me in! */ ', | |
| version: '0.0.0', | |
| git: ' /* Fill me in! */ ' | |
| }); | |
| Package.onUse(function(api) { | |
| api.versionsFrom('1.0'); | |
| api.use('coffeescript', 'server'); | |
| Npm.depends({ | |
| mssql: "1.3.0" | |
| }); | |
| api.addFiles('mssql.coffee'); | |
| }); | |
| Package.onTest(function(api) { | |
| api.use('tinytest'); | |
| api.addFiles('mssql-tests.js'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment