remove outdated/out of place examples
This commit is contained in:
parent
900827d72f
commit
7970e9d575
|
@ -1,46 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var Realm = require('..');
|
||||
|
||||
var filename = "sync.realm";
|
||||
var syncUrl = "realm://127.0.0.1/nodejs/sync.realm";
|
||||
var syncUserToken = "eyJpZGVudGl0eSI6Im5vZGVqcy1kZW1vIn0K";
|
||||
|
||||
function Foo() {}
|
||||
Foo.schema = {
|
||||
name: 'Foo',
|
||||
properties: {
|
||||
name: Realm.Types.STRING,
|
||||
number: Realm.Types.INT,
|
||||
}
|
||||
};
|
||||
|
||||
var realm = new Realm({
|
||||
path: filename,
|
||||
syncUrl: syncUrl,
|
||||
syncUserToken: syncUserToken,
|
||||
schema: [Foo]
|
||||
});
|
||||
|
||||
console.log('Starting...');
|
||||
|
||||
var prompt = require('prompt');
|
||||
prompt.start();
|
||||
|
||||
var run = true;
|
||||
var my_prompt = function() {
|
||||
prompt.get(['command'], function (err, result) {
|
||||
if (err) { return onErr(err); }
|
||||
console.log('Command: ' + result.command);
|
||||
if (result.command == 'exit') {
|
||||
run = false;
|
||||
}
|
||||
|
||||
if (run) {
|
||||
my_prompt();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
my_prompt();
|
||||
|
89
test.js
89
test.js
|
@ -1,89 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
'use strict';
|
||||
|
||||
const Realm = require('.');
|
||||
const prompt = require('prompt');
|
||||
const mkdirp = require('mkdirp');
|
||||
const wildcard = require('wildcard');
|
||||
|
||||
var notifier_dir = './notifier';
|
||||
mkdirp.sync(notifier_dir);
|
||||
|
||||
// var access_token = 'ewoJImlkZW50aXR5IjogImFkbWluIiwKCSJhY2Nlc3MiOiBbInVwbG9hZCIsICJkb3dubG9hZCIsICJtYW5hZ2UiXQp9Cg==:DlFksxA+cJyEOc9bu6JwBUfDi4fJCagjAcIPPsoisjqfmOzSrk5Omuw0IkxCRU534p2+CAAj5IOH47DfObPtAA8q2DHguYDOKWYxyktS/6doPCqDHYN7k9EgUHdPTkESNkuPZbaVfXZTGzocB8m7+MaEXJde7FGPbh1sBz/+sPldnlAhnOqO5QbWzIEyoGHiOSg3V7UCh2H8kalr3tef7fkE2X65OBMgcarPvM5M6sPijOx2N5zrVrjL2wvguP9zS+g2ybFPUqV3DGv3S8cnGA+wVId/jCfGc2ujNhecunJdENH+/pL+0BTYHCFEWkY1WP1NUyti60FwRaXAtcYxeA==';
|
||||
// var admin_user = new Realm.Sync.User.adminUser('http://127.0.0.1:9080/', access_token);
|
||||
// Realm.Sync.setGlobalListener(notifier_dir, 'realm://127.0.0.1:9080', admin_user,
|
||||
// (name) => {
|
||||
// console.log('filter: ' + name);
|
||||
// return true;
|
||||
// },
|
||||
// (name, realm, changes) => {
|
||||
// console.log('change: ' + name);
|
||||
// console.log(changes);
|
||||
// }
|
||||
// );
|
||||
// console.log('global notifier listening...');
|
||||
|
||||
Realm.Sync.setLogLevel('error');
|
||||
|
||||
function createObjects(error, user) {
|
||||
console.log(user.server);
|
||||
console.log(user.token);
|
||||
console.log(user.identity);
|
||||
|
||||
var realm = new Realm({
|
||||
sync: {
|
||||
user: user,
|
||||
url: 'realm://127.0.0.1:9080/~/demo/realm1'
|
||||
},
|
||||
schema: [{
|
||||
name: 'IntObject',
|
||||
properties: {
|
||||
int: 'int'
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
function create(err, result) {
|
||||
if (err) {
|
||||
exit();
|
||||
}
|
||||
if (!err) {
|
||||
realm.write(() => {
|
||||
realm.create('IntObject', {int: parseInt(result.int)});
|
||||
});
|
||||
console.log(realm.objects('IntObject'));
|
||||
}
|
||||
|
||||
prompt.get(['int'], create);
|
||||
}
|
||||
prompt.start();
|
||||
prompt.get(['int'], create);
|
||||
}
|
||||
|
||||
if (Realm.Sync.User.all.length) {
|
||||
console.log('Using persisted user');
|
||||
createObjects(undefined, Realm.Sync.User.all[0]);
|
||||
//Realm.Sync.User.login('http://127.0.0.1:9080/', 'ari', 'aaa', createObjects);
|
||||
}
|
||||
else {
|
||||
console.log('Logging in');
|
||||
Realm.Sync.User.login('http://127.0.0.1:9080/', 'ari', 'aaa', createObjects);
|
||||
//Realm.Sync.User.create('http://127.0.0.1:9080/', 'ari', 'aaa', createObjects);
|
||||
}
|
Loading…
Reference in New Issue