我可以使用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));
据我看文件,没有关于如何写数据的文件。