Download spectrum/api/migrations/20170627104435-user-email-settings.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/migrations/20170627104435-user-email-settings.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/migrations/20170627104435-user-email-settings.js
-
curl -L -o 20170627104435-user-email-settings.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/migrations/20170627104435-user-email-settings.js
1.27 kB
| exports.up = function(r, conn) { | |
| return Promise.all([ | |
| r | |
| .tableCreate('usersSettings') | |
| .run(conn) | |
| // Create secondary indexes | |
| .then(() => | |
| // index user by username | |
| r | |
| .table('usersSettings') | |
| .indexCreate('userId', r.row('userId')) | |
| .run(conn) | |
| ) | |
| .then(() => | |
| Promise.all([ | |
| // Get all user ids while we wait for the index to finish creating | |
| r.table('users').withFields('id').map(user => user('id')).run(conn), | |
| r.table('usersSettings').indexWait('userId').run(conn), | |
| ]) | |
| ) | |
| .then(([userIds]) => userIds.toArray()) | |
| .then(userIds => | |
| Promise.all( | |
| userIds.map(id => | |
| r | |
| .table('usersSettings') | |
| .insert({ | |
| userId: id, | |
| notifications: { | |
| types: { | |
| newMessageInThreads: { | |
| email: true, | |
| }, | |
| }, | |
| }, | |
| }) | |
| .run(conn) | |
| ) | |
| ) | |
| ) | |
| .catch(err => { | |
| console.log(err); | |
| throw err; | |
| }), | |
| ]); | |
| }; | |
| exports.down = function(r, conn) { | |
| return r.tableDrop('usersSettings').run(conn); | |
| }; | |