Here is my db.find():
db.createIndex({
index: {
fields: ['username', 'date'],
name: 'usernameDateIndex',
ddoc: "usernameDateIndex"
}
}).then(() => {
db.find({
selector: {
username: 'org.couchdb.user:' + name
},
sort: [{username: 'desc'}, {date:'desc'}],
use_index: 'usernameDateIndex'
}).then(result => {
// Works fine. I get what is expected
}).catch(error => {
});
}).catch(error => {
});
This works fine and returns an array with six docs. I then delete one doc like this:
doc._deleted = true;
db.put(
doc
).then(response => {
// db.allDocs() returns 5 docs this is correct
// db.find() returns an empty array
}).catch(error => {
});
After the delete, db.AllDocs() works correctly but the same db.createIndex and db.find() listed above returns and empty array. I have also tried db.find() after the delete without the db.createIndex() and I still get an empty array and I get no errors.
Am I missing a step here? Do I need to do some sort of commit after the delete? Do I need to delete the index and create it again? Do I need to force replication with my CouchDB remote server? Not sure what is going on.
One last thing, this is a React Native app that is using pouchdb-react-native and pouchdb-find packages. It's backing storage is AsyncStorage.