你应该使用不同的
path
const Realm = require('realm');
const ItemSchema = {name: 'Item', properties: {id: 'int', name: 'string'}};
const unsynced = new Realm({
path: 'unsynced.realm',
schema: [ItemSchema],
})
Realm.Sync.User.register('http://localhost:9080', 'user1', 'pass1', (error, user) => {
const synced = new Realm({
path: 'synced.realm',
schema: [ItemSchema],
sync: {
url: 'realm://localhost:9080/~/synced',
user: user,
},
})
synced.close();
user.logout();
unsynced.close();
})