Skip to content

Instantly share code, notes, and snippets.

Avatar

Alysson Melo alyssoncm

View GitHub Profile
View cloud-code-validator-sample-3.js
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,
View cloud-code-validator-sample-2.js
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
View live-query-12.js
subscription.on('open', async () => {
console.log('subscription opened');
todos = {};
todos = (await query.find()).reduce((todos, todo) => ({
...todos,
[todo.id]: todo
}), todos);
printTodos();
});
View live-query-10.js
subscription.on('close', () => {
console.log('subscription closed');
});
View live-query-9.js
subscription.on('delete', todo => {
console.log(`todo ${todo.id} deleted`);
});
View live-query-8.js
subscription.on('leave', todo => {
console.log(`todo ${todo.id} left`);
});
View live-query-7.js
subscription.on('enter', todo => {
console.log(`todo ${todo.id} entered`);
});
View live-query-6.js
subscription.on('update', todo => {
console.log(`todo ${todo.id} updated`);
});
View live-query-5.js
subscription.on('create', todo => {
console.log(`todo ${todo.id} created`);
});