1
我想插入简单的文字来蒙戈数据库反应,但是,当我提交表单打印此行控制台:插入失败:法流星1.3和反应
insert failed: Method '/resolutions/insert' not found
提示:autopublish
和insecure
已安装。和我反应15和流星1.3.1
这里是我的代码:
import { Meteor } from 'meteor/meteor';
import React from 'react';
import ReactDOM from 'react-dom';
Resolutions = new Mongo.Collection('resolutions');
Resolutions.allow({
insert: function(userId,doc) {
return true;
}
});
// import './index.html';
export default class App extends React.Component {
AddResolution(event) {
let text = this.refs.resolutions.value.trim();
// Insert into database
Resolutions.insert({
text: text,
complete: false,
createAt: new Date()
});
this.refs.resolutions.value = "";
event.preventDefault();
}
render() {
return (
<div>
<h1>My swsolutions</h1>
<form className="new-resolution" onSubmit={this.AddResolution.bind(this)}>
<input type="text" ref="resolutions" placeholder="Finish React Meteor"/>
</form>
</div>
);
}
}
集合还需要在服务器上定义。 –
另外,'collection.allow'是一个服务器端函数。 – aedm
@DavidWeldon谢谢,现在工作。 – Sajad