По какой-то причине я получаю сообщение «post.save не является функцией» при использовании функции .save() для астрономии v2. Я попытался вызвать .save() при вставке нового doc в db, используя вызов методов meteor с клиентской стороны.Meteor jagi: астрономия .save функция не работает
Вот код:
import { Class } from 'meteor/jagi:astronomy';
import { Mongo } from 'meteor/mongo';
const Posts = new Mongo.Collection("Posts");
const Post = Class.create({
name: 'Post',
Collection : Posts,
secured: true,
fields: {
title: String,
published: Boolean,
/* ... */
},
methods: {
rename(title) {
// Check if a given user can rename this post.
if (this.ownerId !== Meteor.userId()) {
throw new Meteor.Error(403, 'You are not an owner');
}
this.title = this;
this.save();
},
publish() {
// Check if a given user can publish this post.
if (this.ownerId !== Meteor.userId()) {
throw new Meteor.Error(403, 'You are not an owner');
}
if (this.published) {
throw new Meteor.Error(403, 'Post is already published');
}
this.published = true;
this.save();
}
}
});
Meteor.methods({
"newPost"(){
const post = new Post();
post.title = "test";
post.save();
},
"renamePost"(postId, title) {
const post = Post.findOne(postId);
post.rename(title);
},
"publishPost"(postId) {
const post = Post.findOne(postId);
post.publish();
}
});
Как вы можете видеть, им с помощью образцов по документации астрономии с дополнительными методами, называемых newPost.
вызова на те функции, все это привело к исключению
TypeError: post.save is not a function
попытался следующие попытки по разрешению ошибки без успеха
Удаление и повторное добавление астрономии
Перестроить метеорный проект
Обновление до версии 2.1.2
Thx для ответов!