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
Parse.Cloud.define("DogsWithRegex", async (request) => { | |
// Returns all Dogs that are owned by a given name. The name must be at least 3 characters long to be valid. | |
const query = new Parse.Query("Dog"); | |
query.equalTo("owner", request.params.owner); // We use the owner parameter to match | |
const results = await query.find(); | |
return results; | |
},{ | |
fields : { | |
owner : { | |
required: true, |
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
Parse.Cloud.define("DogsBetweenAges", async (request) => { | |
// Returns all Dogs that are between two given ages | |
const query = new Parse.Query("Dog"); | |
query.greaterThanOrEqualTo("minimumAge", request.params.minimumAge); // Uses the minimumAge parameter | |
query.lessThanOrEqualTo("maximumAge", request.params.maximumAge); // Uses the maximumAge parameter | |
const results = await query.find(); | |
return results | |
},{ | |
fields : ['minimumAge', 'maximumAge'], | |
requireUser: true |
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
subscription.on('open', async () => { | |
console.log('subscription opened'); | |
todos = {}; | |
todos = (await query.find()).reduce((todos, todo) => ({ | |
...todos, | |
[todo.id]: todo | |
}), todos); | |
printTodos(); | |
}); |
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
let todos = {}; |
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
subscription.on('close', () => { | |
console.log('subscription closed'); | |
}); |
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
subscription.on('delete', todo => { | |
console.log(`todo ${todo.id} deleted`); | |
}); |
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
subscription.on('leave', todo => { | |
console.log(`todo ${todo.id} left`); | |
}); |
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
subscription.on('enter', todo => { | |
console.log(`todo ${todo.id} entered`); | |
}); |
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
subscription.on('update', todo => { | |
console.log(`todo ${todo.id} updated`); | |
}); |
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
subscription.on('create', todo => { | |
console.log(`todo ${todo.id} created`); | |
}); |