Created
September 14, 2012 22:53
-
-
Save tracker1/3725475 to your computer and use it in GitHub Desktop.
Module exports in coffeescript
This file contains 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
# Without the anonymous function wrapper, it seemed to only export the first value. | |
(-> | |
exports.getTopOfQueue = """ | |
SELECT TOP 10 | |
[Id],[CreatedOn],[LastAttemptOn],[Application],[Class],[From],[To],[Subject],[BodyUrl],[BodyHtml],[JsonDetails] | |
FROM [EmailQueue] | |
WHERE [LastAttemptOn] < DATEADD(m, -15, SYSUTCDATETIME()) | |
ORDER BY [Id] | |
""" | |
exports.unsentEmailQueueItem=""" | |
UPDATE [EmailQueue] | |
SET [LastAttemptedOn] = SYSUTCDATETIME() | |
,[JsonDetails] = @details | |
WHERE [Id] = @id | |
""" | |
exports.sentEmailQueueItem=""" | |
BEGIN TRANS | |
INSERT INTO [EmailSent] ([CreatedOn],[LastAttemptOn],[Application],[Class],[From],[To],[Subject],[BodyUrl],[BodyHtml],[JsonDetails]) | |
SELECT eq.[CreatedOn] | |
,eq.[LastAttemptOn] | |
,eq.[Application] | |
,eq.[Class] | |
,eq.[From] | |
,eq.[To] | |
,eq.[Subject] | |
,eq.[BodyUrl] | |
,@bodyHtml | |
,@details | |
FROM [EmailQueue] eq | |
WHERE eq.[Id] = @id; | |
DELETE FROM [EmailQueue] WHERE [Id] = @id; | |
COMMIT TRANS | |
""" | |
)() #end anonymous self-executing function |
If I wrap the entire thing in an anonymous self executing function, it seems to work... (<- ... )()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
console.dir(require("./sqltext")) outputs { getTopOfQueue: '...' } not the rest.