Skip to content

where in the getDocuments query does not work for $createdAt field #2303

Closed

Description

@owl352

I was sorting through the documents and noticed that there are fields that search fine, and there are fields that don't search fine

Expected Behavior

When I request all the documents for an address, I get the correct response with the correct number of documents

await this.client.platform.documents.get('withdrawal.withdrawal', {
  where: [
    ['$ownerId', '==', identifier],
  ],
  limit
})

Next, I looked at the $createdAt timestamp for one of the documents and I request with new data

const test = await this.client.platform.documents.get('withdrawal.withdrawal', {
  where: [
    ['$createdAt', '==', 1728505440651],
  ],
  limit
})

I should get 1 document in the response

Current Behavior

However, I end up with an empty array in the response

const docsResp = await this.client.platform.documents.get('withdrawal.withdrawal', {
  where: [
    ['$ownerId', '==', '8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc'],
  ],
  limit
})

const docs = docsResp.map(v=>v.toJSON())
const createdAt = docs[0].$createdAt

console.log(`Founded: ${docsResp.length}`)
console.log(`Documents: ${JSON.stringify(docs)}`)
console.log(`First timestamp for $createdAt: ${createdAt}`)

const docsRespByCreatedAt = await this.client.platform.documents.get('withdrawal.withdrawal', {
  where: [
    ['$createdAt', '==', createdAt],
  ],
  limit
})

console.log(`Founded in second response: ${docsRespByCreatedAt.length}`)
console.log(`Documents in second response: ${JSON.stringify(docsRespByCreatedAt)}`)
LOGS

> [email protected] start
> node index.js

Founded: 10
Documents: [{"$id":"H1BCmapp3m9xMU3x2RNweFndEs8QJ5v2ABAvUVBgVaaZ","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":200000,"coreFeePerByte":5,"outputScript":"dqkU9RRTpTjZoKn7P+DylIoPgNnPUlqIrA==","pooling":0,"status":3,"transactionIndex":24,"transactionSignHeight":1118602,"$revision":4,"$createdAt":1728505440651,"$updatedAt":1728554039974,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"HEdA6MspFcvDf7j6i7qidf9pdrVZK4x5pBu8NEB3VhTn","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":190000,"coreFeePerByte":5,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":22,"transactionSignHeight":1118602,"$revision":4,"$createdAt":1728500271509,"$updatedAt":1728554039974,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"J7Ff15VpiXaEv8A7xa6U5aq9WG9sN4iEQffThbi6wJSh","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":190000,"coreFeePerByte":5,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":23,"transactionSignHeight":1118602,"$revision":4,"$createdAt":1728500510399,"$updatedAt":1728554039974,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"2TEs6667q4fCKiGVondLr6D1rosXcvQoKGoXrsdtRzQb","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":400000,"coreFeePerByte":1,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":37,"transactionSignHeight":1125193,"$revision":4,"$createdAt":1729431555604,"$updatedAt":1729495850491,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"ETgifEvB92dFtgsWQMBYz6HZJkb4QURYi2DAu86PndUw","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":400000,"coreFeePerByte":1,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":39,"transactionSignHeight":1125193,"$revision":4,"$createdAt":1729489601467,"$updatedAt":1729495850491,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"FbA8r9scNa2n4YB3jkdHK1aaaURnGf5fmU1UAKvLLLhN","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":400000,"coreFeePerByte":1,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":38,"transactionSignHeight":1125193,"$revision":4,"$createdAt":1729439223626,"$updatedAt":1729495850491,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"8AVaSJdHLBBMgYwmCHuqBXc5TeFMptGFZ7LM5prZ2Yq2","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":400000,"coreFeePerByte":1,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":40,"transactionSignHeight":1126709,"$revision":4,"$createdAt":1729534066861,"$updatedAt":1729693354211,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"8DxrbdLMihzJu8c5VEvSMdm9nRCEiE6Tyc9nVQ9f5Pmg","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":4000000,"coreFeePerByte":1,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":54,"transactionSignHeight":1127775,"$revision":4,"$createdAt":1729791480658,"$updatedAt":1729819436017,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"6ow45AvJ4jBdHxsCVUH1PGy1xEw9yg3hAC1jfohQ8ioG","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":4000000,"coreFeePerByte":1,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":80,"transactionSignHeight":1131337,"$revision":4,"$createdAt":1730297997769,"$updatedAt":1730328609682,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"},{"$id":"E1FZpGixJSXmAwwEtCxqHpGM3XeFyFKLdNSCQMmzFJko","$ownerId":"8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc","amount":4000000,"coreFeePerByte":1,"outputScript":"dqkUT5vx/UWS1NGHPxErcfXG2a3sicmIrA==","pooling":0,"status":3,"transactionIndex":81,"transactionSignHeight":1131337,"$revision":4,"$createdAt":1730311760674,"$updatedAt":1730328609682,"$transferredAt":null,"$createdAtBlockHeight":null,"$updatedAtBlockHeight":null,"$transferredAtBlockHeight":null,"$createdAtCoreBlockHeight":null,"$updatedAtCoreBlockHeight":null,"$transferredAtCoreBlockHeight":null,"$dataContract":{"$format_version":"0","id":"4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6","config":{"$format_version":"0","canBeDeleted":false,"readonly":false,"keepsHistory":false,"documentsKeepHistoryContractDefault":false,"documentsMutableContractDefault":true,"documentsCanBeDeletedContractDefault":true,"requiresIdentityEncryptionBoundedKey":null,"requiresIdentityDecryptionBoundedKey":null},"version":1,"ownerId":"11111111111111111111111111111111","schemaDefs":null,"documentSchemas":{"withdrawal":{"description":"Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition","creationRestrictionMode":2,"type":"object","indices":[{"name":"identityStatus","properties":[{"$ownerId":"asc"},{"status":"asc"},{"$createdAt":"asc"}],"unique":false},{"name":"identityRecent","properties":[{"$ownerId":"asc"},{"$updatedAt":"asc"},{"status":"asc"}],"unique":false},{"name":"pooling","properties":[{"status":"asc"},{"pooling":"asc"},{"coreFeePerByte":"asc"},{"$updatedAt":"asc"}],"unique":false},{"name":"transaction","properties":[{"status":"asc"},{"transactionIndex":"asc"}],"unique":false}],"properties":{"transactionIndex":{"type":"integer","description":"Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction","minimum":1,"position":0},"transactionSignHeight":{"type":"integer","description":"The Core height on which transaction was signed","minimum":1,"position":1},"amount":{"type":"integer","description":"The amount to be withdrawn","minimum":1000,"position":2},"coreFeePerByte":{"type":"integer","description":"This is the fee that you are willing to spend for this transaction in Duffs/Byte","minimum":1,"maximum":4294967295,"position":3},"pooling":{"type":"integer","description":"This indicated the level at which Platform should try to pool this transaction","enum":[0,1,2],"position":4},"outputScript":{"type":"array","byteArray":true,"minItems":23,"maxItems":25,"position":5},"status":{"type":"integer","enum":[0,1,2,3,4],"description":"0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired","position":6}},"additionalProperties":false,"required":["$createdAt","$updatedAt","amount","coreFeePerByte","pooling","outputScript","status"]}}},"$type":"withdrawal"}]
First timestamp for $createdAt: 1728505440651
Founded in second response: 0
Documents in second response: []

Possible Solution

Steps to Reproduce (for bugs)

  1. create new empty node project
  2. install dash-sdk package
  3. init client with withdrawal contractId in apps
  4. try to find documents by $createdAt

Context

Your Environment

  • Version used:
    • dash: 4.5.0
  • node: v20.16.0

Activity

  1. added
    bug
    on Nov 2, 2024
  2. changed the title [-]`where` in the search for documents does not work for some fields[/-] [+]`where` in the getDocuments query does not work for $createdAt field[/+] on Nov 8, 2024
  3. QuantumExplorer commented on Nov 9, 2024

    @QuantumExplorer
    Member

    @owl352 there is actually no issue here in the low level system, and more likely an issue in the JS-SDK, because there is no index on $createdAt, and hence it will try to find the next best index to use. Which in this case would be

           "name": "identityStatus",
           "properties": [
             {
               "$ownerId": "asc"
             },
             {
               "status": "asc"
             },
             {
               "$createdAt": "asc"
             }
           ],
           "unique": false
         },```
         
        Because of how limits work it will go depth first looking for $createdAt, and since it didn't find anything will return nothing within 100 sub trees.
    
  4. owl352 commented on Nov 10, 2024

    @owl352
    ContributorAuthor

    @QuantumExplorer Thank you! I figured it out, now '==' works, but now I don't really understand how to search with non-strict equals, because in this case we need to use orderBy, and according to the documentation it accepts only 2 fields.

  5. riongull commented on Nov 10, 2024

    @riongull

    What was the issue @owl352?

    Something simple like making 1728505440651 a string, something trickier that needs better documentation?

  6. owl352 commented on Nov 10, 2024

    @owl352
    ContributorAuthor

    @riongull
    More like something simple. I only had a search on $createdAt and the index contains 2 other fields, but explaining this point didn't help me. At the moment I can find a document by $createdAt with strict equality for $createdAt, status, $ownerId, however I have a use case where status is unknown and the logical solution is to use ['status', '>=', 0], however in that case I have to use orderBy which only accepts 2 fields and with any combination of these fields I get either an error or an empty array

  7. owl352 commented on Nov 10, 2024

    @owl352
    ContributorAuthor

    @riongull More like something simple. I only had a search on $createdAt and the index contains 2 other fields, but explaining this point didn't help me. At the moment I can find a document by $createdAt with strict equality for $createdAt, status, $ownerId, however I have a use case where status is unknown and the logical solution is to use ['status', '>=', 0], however in that case I have to use orderBy which only accepts 2 fields and with any combination of these fields I get either an error or an empty array

    working:

    const docsRespByCreatedAt = await this.client.platform.documents.get('withdrawal.withdrawal', {
      where: [
        ['$createdAt', '==', createdAt],
        ['$ownerId', '==', '8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc'],
        ['status', '==', 3]
      ],
    })

    not working (also with orderBy):

    const docsRespByCreatedAt = await this.client.platform.documents.get('withdrawal.withdrawal', {
      where: [
        ['$createdAt', '==', createdAt],
        ['$ownerId', '==', '8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc'],
        ['status', '>=', 0]
      ],
    })
  8. owl352 commented on Nov 11, 2024

    @owl352
    ContributorAuthor
  9. added a commit that references this issue on Nov 11, 2024
  10. owl352 commented on Nov 16, 2024

    @owl352
    ContributorAuthor

    @QuantumExplorer
    Faced a problem with installing startAfter. I think I did everything correctly. In the end I get an empty array if I specify where and startAfter
    image
    image
    image

  11. QuantumExplorer commented on Nov 20, 2024

    @QuantumExplorer
    Member

    Interesting, let me think about the problem.

  12. QuantumExplorer commented on Nov 21, 2024

    @QuantumExplorer
    Member

    @owl352 excellent find, in this case the index chosen is the closest index:
    { "name": "identityRecent", "properties": [ { "$ownerId": "asc" }, { "$updatedAt": "asc" }, { "status": "asc" } ], "unique": false },
    There's a problem with the path query that we generate from the query where we take all fields and do a >, except that it should be only the top field. If that didn't make sense don't worry. I'll fix it soon.

  13. QuantumExplorer commented on Nov 25, 2024

    @QuantumExplorer
    Member

    This has been fixed, will be in 1.6 @owl352 . Thanks again for finding it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions