Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow declaration-only tables for TS users. #1136

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/classes/version/schema-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dexie } from '../dexie';
import { DbSchema } from '../../public/types/db-schema';
import { setProp, keys, slice, _global, isArray, shallowClone, isAsyncFunction, defineProperty } from '../../functions/utils';
import { setProp, keys, slice, _global, isArray, shallowClone, isAsyncFunction, defineProperty, getPropertyDescriptor } from '../../functions/utils';
import { Transaction } from '../transaction';
import { Version } from './version';
import Promise, { PSD, newScope, NativePromise, decrementExpectedAwaits, incrementExpectedAwaits } from '../../helpers/promise';
Expand All @@ -17,7 +17,9 @@ export function setApiOnPlace(db: Dexie, objs: Object[], tableNames: string[], d
tableNames.forEach(tableName => {
const schema = dbschema[tableName];
objs.forEach(obj => {
if (!(tableName in obj)) {
const propDesc = getPropertyDescriptor(obj, tableName);
if (!propDesc || ("value" in propDesc && propDesc.value === undefined)) {
// Either the prop is not declared, or it is initialized to undefined.
if (obj === db.Transaction.prototype || obj instanceof db.Transaction) {
// obj is a Transaction prototype (or prototype of a subclass to Transaction)
// Make the API a getter that returns this.table(tableName)
Expand Down