mirror of
https://github.com/appy-one/acebase.git
synced 2026-06-30 06:02:02 -06:00
new browser build
This commit is contained in:
parent
7f89e94dda
commit
877cd5494e
2 changed files with 38 additions and 15 deletions
51
dist/browser.js
vendored
51
dist/browser.js
vendored
|
|
@ -640,6 +640,8 @@ class DataReference {
|
|||
|
||||
let authorized = this.db.api.subscribe(this.path, event, cb.ours);
|
||||
const allSubscriptionsStoppedCallback = () => {
|
||||
let callbacks = this[_private].callbacks;
|
||||
callbacks.splice(callbacks.indexOf(cb), 1);
|
||||
this.db.api.unsubscribe(this.path, event, cb.ours);
|
||||
};
|
||||
if (authorized instanceof Promise) {
|
||||
|
|
@ -2243,12 +2245,14 @@ class TypeMappings {
|
|||
}
|
||||
|
||||
if (typeof options.serializer === 'undefined') {
|
||||
if (typeof type.prototype.serialize === 'function') {
|
||||
// Use .serialize instance method
|
||||
options.serializer = type.prototype.serialize;
|
||||
}
|
||||
// if (typeof type.prototype.serialize === 'function') {
|
||||
// // Use .serialize instance method
|
||||
// options.serializer = type.prototype.serialize;
|
||||
// }
|
||||
|
||||
// Use object's serialize method upon serialization (if available)
|
||||
}
|
||||
if (typeof options.serializer === 'string') {
|
||||
else if (typeof options.serializer === 'string') {
|
||||
if (typeof type.prototype[options.serializer] === 'function') {
|
||||
options.serializer = type.prototype[options.serializer];
|
||||
}
|
||||
|
|
@ -2299,6 +2303,9 @@ class TypeMappings {
|
|||
if (this.serializer) {
|
||||
obj = this.serializer.call(obj, ref, obj);
|
||||
}
|
||||
else if (obj && typeof obj.serialize === 'function') {
|
||||
obj = obj.serialize(ref, obj);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
|
|
@ -5103,7 +5110,7 @@ module.exports = {
|
|||
const { debug, ID, PathReference, PathInfo, ascii85 } = require('acebase-core');
|
||||
const { NodeInfo } = require('./node-info');
|
||||
const { VALUE_TYPES } = require('./node-value-types');
|
||||
const { Storage, StorageSettings } = require('./storage');
|
||||
const { Storage, StorageSettings, NodeNotFoundError } = require('./storage');
|
||||
|
||||
class LocalStorageSettings extends StorageSettings {
|
||||
constructor(settings) {
|
||||
|
|
@ -5178,7 +5185,7 @@ class LocalStorage extends Storage {
|
|||
}
|
||||
})
|
||||
.then(() => {
|
||||
return this.indexes.load();
|
||||
return this.indexes.supported && this.indexes.load();
|
||||
})
|
||||
.then(() => {
|
||||
this.emit('ready');
|
||||
|
|
@ -5724,15 +5731,15 @@ class LocalStorage extends Storage {
|
|||
const targetRow = this._readNode(path);
|
||||
if (!targetRow) {
|
||||
// Lookup parent node
|
||||
if (path === '') { return null; } // path is root. There is no parent.
|
||||
if (path === '') { return { value: null }; } // path is root. There is no parent.
|
||||
return lock.moveToParent()
|
||||
.then(parentLock => {
|
||||
lock = parentLock;
|
||||
let parentNode = this._readNode(pathInfo.parentPath);
|
||||
if ([VALUE_TYPES.OBJECT, VALUE_TYPES.ARRAY].includes(parentNode.type) && pathInfo.key in parentNode) {
|
||||
return parentNode[pathInfo.key];
|
||||
if (parentNode && [VALUE_TYPES.OBJECT, VALUE_TYPES.ARRAY].includes(parentNode.type) && pathInfo.key in parentNode) {
|
||||
return { revision: parentNode.revision, value: parentNode.value[pathInfo.key] };
|
||||
}
|
||||
return null;
|
||||
return { value: null };
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -5842,8 +5849,6 @@ class LocalStorage extends Storage {
|
|||
throw new Error(`multiple records found for non-object value!`);
|
||||
}
|
||||
|
||||
lock.release();
|
||||
|
||||
// Post process filters to remove any data that got though because they were
|
||||
// not stored in dedicated records. This will happen with smaller values because
|
||||
// they are stored inline in their parent node.
|
||||
|
|
@ -5886,6 +5891,10 @@ class LocalStorage extends Storage {
|
|||
}
|
||||
return result;
|
||||
})
|
||||
.then(result => {
|
||||
lock.release();
|
||||
return result;
|
||||
})
|
||||
.catch(err => {
|
||||
lock.release();
|
||||
throw err;
|
||||
|
|
@ -6291,6 +6300,16 @@ class Storage extends EventEmitter {
|
|||
const _indexes = [];
|
||||
const storage = this;
|
||||
this.indexes = {
|
||||
/**
|
||||
* Tests if (the default storage implementation of) indexes are supported in the environment.
|
||||
* They are currently only supported when running in Node.js because they use the fs filesystem.
|
||||
* TODO: Implement storage specific indexes (eg in SQLite, MySQL, MSSQL, in-memory)
|
||||
*/
|
||||
get supported() {
|
||||
const pfs = require('./promise-fs');
|
||||
return pfs && pfs.hasFileSystem;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates an index on specified path and key(s)
|
||||
* @param {string} path location of objects to be indexed. Eg: "users" to index all children of the "users" node; or "chats/*\/members" to index all members of all chats
|
||||
|
|
@ -6594,6 +6613,10 @@ class Storage extends EventEmitter {
|
|||
|
||||
} // end of constructor
|
||||
|
||||
get path() {
|
||||
return `${this.settings.path}/${this.name}.acebase`;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Once storage is ready for use, the optional callback will fire
|
||||
// * and the returned promise will resolve.
|
||||
|
|
@ -7094,7 +7117,7 @@ class Storage extends EventEmitter {
|
|||
* @param {string[]} [options.exclude] child paths to exclude
|
||||
* @param {boolean} [options.child_objects] whether to inlcude child objects and arrays
|
||||
* @param {string} [options.tid] optional transaction id for node locking purposes
|
||||
* @returns {Promise<{ revision: string, value: any}>}
|
||||
* @returns {Promise<{ revision?: string, value: any}>}
|
||||
*/
|
||||
getNode(path, options = { include: undefined, exclude: undefined, child_objects: true, tid: undefined }) {
|
||||
throw new Error(`This method must be implemented by subclass`);
|
||||
|
|
|
|||
2
dist/browser.min.js
vendored
2
dist/browser.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue