Skip to content

Instantly share code, notes, and snippets.

@alyssoncm
Last active November 20, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alyssoncm/e355813d3c57efc9d2dc4f79a003a1a5 to your computer and use it in GitHub Desktop.
Save alyssoncm/e355813d3c57efc9d2dc4f79a003a1a5 to your computer and use it in GitHub Desktop.
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,
type: String,
options: val => {
return val.length >= 3; // will return TRUE if the length of the string is >= 3
},
error: "The Owner's name must have at least 3 characters"
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment