Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pelias/placeholder
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.0
Choose a base ref
...
head repository: pelias/placeholder
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.1.0
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on Apr 24, 2020

  1. Copy the full SHA
    b7d9306 View commit details
Showing with 26 additions and 26 deletions.
  1. +5 −6 cmd/load.js
  2. +1 −1 lib/Database.js
  3. +1 −0 lib/DocStore.js
  4. +19 −19 test/lib/Database.js
11 changes: 5 additions & 6 deletions cmd/load.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

var split = require('split2'),
through = require('through2'),
parser = require('../lib/jsonParseStream'),
Placeholder = require('../Placeholder'),
ph = new Placeholder();
const split = require('split2');
const through = require('through2');
const parser = require('../lib/jsonParseStream');
const Placeholder = require('../Placeholder');
const ph = new Placeholder();

// run import pipeline
console.error('import...');
2 changes: 1 addition & 1 deletion lib/Database.js
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ Database.prototype.configure = function(){
this.db.pragma('page_size=4096'); // (default: 1024)
this.db.pragma('cache_size=-2000'); // (default: -2000, 2GB)
this.db.pragma('synchronous=OFF');
this.db.pragma('journal_mode=OFF');
this.db.pragma('journal_mode=MEMORY');
this.db.pragma('temp_store=MEMORY');
};

1 change: 1 addition & 0 deletions lib/DocStore.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ util.inherits( DocStore, Database );

DocStore.prototype.reset = function(){
this.db.exec('DROP TABLE IF EXISTS docs');
this.db.exec('DROP TABLE IF EXISTS rtree');
this.db.exec('CREATE TABLE docs( id INTEGER PRIMARY KEY, json TEXT )');

// create rtree table
38 changes: 19 additions & 19 deletions test/lib/Database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var Database = require('../../lib/Database');
const _ = require('lodash');
const Database = require('../../lib/Database');

module.exports.constructor = function(test, common) {
test('constructor', function(t) {
@@ -87,20 +87,20 @@ module.exports.prepare = function(test, common) {
test('prepare', function(t) {
var db = new Database();
db.open('/tmp/db', { test: true });

t.equal(typeof db.stmt, 'undefined');

const sql = 'SELECT * FROM sqlite_master';
db.prepare(sql);

t.true(typeof db.stmt, 'object');
t.true(db.stmt.hasOwnProperty(sql));
t.deepEqual(db.stmt[sql], {
reader: true,
source: 'SELECT * FROM sqlite_master',
database: db.db
});

t.end();
});
};
@@ -111,19 +111,19 @@ module.exports.configure = function(test, common) {
db.open('/tmp/db', { test: true });

// configure
const pragma_checks = [
{ foreign_keys: 0 },
{ page_size: 4096 },
{ cache_size: -2000 },
{ synchronous: 0 },
// { journal_mode: 0 },
{ temp_store: 2 }
];

t.plan( pragma_checks.length );
pragma_checks.forEach( pragma => {
var sql = 'PRAGMA ' + Object.keys(pragma)[0] + ';';
t.deepEqual( db.db.prepare(sql).get(), pragma );
const pragma_checks = {
foreign_keys: 0,
page_size: 4096,
cache_size: -2000,
synchronous: 0,
// journal_mode: 'memory',
temp_store: 2
};

t.plan(_.size(pragma_checks));
_.forEach(pragma_checks, (value, key) => {
const stmt = db.db.prepare(`PRAGMA ${key};`);
t.deepEqual(stmt.get(), { [key]: value });
});
});
};