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

use findOne().$ to subscribe a document, but the document's reference is not equal to the document's reference which created by newDocument #3777

Closed
wants to merge 1 commit into from
Closed
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
50 changes: 50 additions & 0 deletions test/unit/bug-report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,54 @@ describe('bug-report.test.js', () => {
db.destroy();
dbInOtherTab.destroy();
});

it('use findOne().$ to subscribe a document, the reference should equal to document which created by newDocument', async () => {
// generate a random database-name
const name = randomCouchString(10);

// create a schema
const mySchema = {
version: 0,
primaryKey: 'id',
type: 'object',
properties: {
id: {
type: 'string',
maxLength: 100,
},
name: {
type: 'string'
}
},
};

// create a database
const db = await createRxDatabase({
name,
/**
* By calling config.storage.getStorage(),
* we can ensure that all variations of RxStorage are tested in the CI.
*/
storage: config.storage.getStorage(),
eventReduce: true,
ignoreDuplicate: true
});
// create a collection
await db.addCollections({
mycollection: {
schema: mySchema
}
});

let docOuter;
db.mycollection.findOne('1').$.subscribe((doc) => (docOuter = doc));

const docNew = db.mycollection.newDocument({ id: '1', name: 'name-1' });

await docNew.save();

console.log('docOuter: ', docOuter)

assert.strictEqual(docOuter === docNew, true)
})
});