Last active
December 14, 2016 17:22
-
-
Save lyzs90/8cfc746ebe4d9c8d3f01d0ee5861e667 to your computer and use it in GitHub Desktop.
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
| // Count Query | |
| MongoClient.connectAsync(uri) | |
| .then((db) => { | |
| return db.collection(collection).countAsync(session.userData.selector); | |
| }) | |
| .then((count) => { | |
| console.log(`Success: Total of ${count} records`); | |
| session.userData.count = count; | |
| }) | |
| .catch((err) => { | |
| throw err; | |
| }); | |
| // Find Query | |
| MongoClient.connectAsync(uri) | |
| .then((db) => { | |
| return db.collection(collection).findAsync(session.userData.selector, { | |
| 'limit': 5, | |
| 'skip': session.userData.cursor | |
| }); | |
| }) | |
| .then((cursor) => { | |
| return cursor.toArrayAsync(); | |
| }) | |
| .then((arr) => { | |
| let tmpDeck = []; | |
| createDeck(session, tmpDeck, arr, 5); | |
| let msg = new builder.Message(session) | |
| .attachmentLayout(builder.AttachmentLayout.carousel) | |
| return session.send(msg); | |
| }) | |
| .then(() => { | |
| session.userData.cursor += 5; | |
| return session.replaceDialog('moreResults:/'); | |
| }) | |
| .catch((err) => { | |
| throw err; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment