How to require a field in a form using mongodb?


Good day I create a form with a field of name and a field of score(number). I want to require the name field and make the score field optional only when i click the submit button. How can i do it ? Im using MongoDB. i tried using if else stement. but i also want to know how to set required field in MongoDB’s way. any advice and opinion to make the code efficient and better will be appreciated

here is the code

<template name="addPlayerForm">
		<input type="text" name="playerName" placeholder="name">
		<input type="nubmer" name="setScore" placeholder="initial score">
		<input type="submit" value="Add Player">

	'submit form': function(event){
		var playerNameVar =;
		var playerScore =;

				name: playerNameVar,
				score: playerScore
			}); = "name"; = "score";
		}else{ = "name is required";


MongoDB doesn’t enforce a schema. If you want to do that, use the popular Collection2 package: