我可以使用 NodeJS 注册用户和登录。接下来我想向ROS2写入数据,我写了这段代码参考here 但发生错误。
Error: Object type 'Vist' not found in schema.
如何将数据写入ROS2?
const registerUser = () => new Promise((resolve, reject) => {
Realm.Sync.User.register(URL, username, password, (err, res) => {
if (err) {
return reject(err);
}
console.log('finish register');
resolve();
})
});
const login = () => new Promise((resolve, reject) => {
Realm.Sync.User.login(URL, username, password, (err, user) => {
if (err) {
return reject(err);
}
resolve(user.token);
})
});
const registerVisit = (token) => new Promise((resolve, reject) => {
const visitSchema = {
name: 'Visit',
properties: {
id: 'int',
oneday_id: 'string',
arrival_date: 'string',
departure_date: 'string',
latitude: 'double',
longitude: 'double',
is_hidden: 'bool',
}
};
Realm.open({ schema: [visitSchema] })
.then(realm => {
realm.write(() => {
realm.create('Vist', {
id: 1,
oneday_id: "ABCD-EFGH-IJKL-MNOP-QRST",
arrival_date: "2017-11-05 11:11:11",
departure_date: "2017-11-05 22:22:22",
latitude: 23.1234567,
longitude: 12.34567,
is_hidden: false,
});
});
resolve();
})
.catch(err => reject(err));
});
login()
.then(() => registerVisit())
.catch(err => console.log(err));
据我查看文档,没有关于如何写入数据的文档。