Any Crud example for Meteor and react with SimpleSchema


#1

I make a simple page where data is inserted into database by a form using Refs of react.Can any body help me out how i can insert the data using aldeed:Simple schema or any curd example using that package.

please check my simple code for insertion.

import React,{Component} from ‘react’;

import {DoctorsList} from ‘…/…/…/api/lists/DoctorsList.js’;

export class DoctorCreate extends Component
{
addDoctor(event){
event.preventDefault();
var text= this.refs.DoctorName.value.trim();
console.log(text);

        DoctorsList.insert({
            name:text,
            createdAt: new Date(),
            owner: Meteor.userId(),           // _id of logged in user
            username: Meteor.user().username,  // username of logged in user
        });
    this.refs.DoctorName.value="";
}
render()
{
    return (
        <div className="container">
        <div className="row">
            <div className="col-sm-12">
            <form className="form" onSubmit={this.addDoctor.bind(this)}>
                <div className="form-group">
                    <label> Name</label>
                <input ref="DoctorName" type="text" className="form-control" placeholder="name..."/>
                </div>
             <div className="form-group">
                <input type="submit" value="save" className="btn btn-primary"/>
            </div>
            </form>
            </div>
            <br/>
            <a href="/doctors"  >Back to list </a>
            <hr/>
        </div>
        </div>
    )
}

}

Thanks in Advance


#2

hi @omerabb

I havn’t yet tried this: https://github.com/zeroasterisk/react-form-simple-schema

let us know how it went

cheers