|
| CaDbRecordModel (MController *aMController, const MModelProtocolInterface &aModel) |
|
| ~CaDbRecordModel () |
|
QString | publishDbRecord (CaDbRecord &aRecord, const QList< Hash > *aRecordReaders=NULL) |
| method for storing and publishing a database record. More...
|
|
QList< CaDbRecord * > | searchRecords (const Hash &aFromCollection, const Hash &aById=KNullHash, const quint32 aModifiedAfter=0, const quint32 aModifiedBefore=std::numeric_limits< quint32 >::max(), const qint64 aByHavingNumberMoreThan=std::numeric_limits< qint64 >::min(), const qint64 aByHavingNumberLessThan=std::numeric_limits< qint64 >::max(), const QString &aBySearchPhrase=QString::null, const Hash &aBySender=KNullHash, const bool aForPublish=false) |
|
bool | publishedCaDbRecordReceived (CaDbRecord &aRecord, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aFromNode) |
|
bool | sentCaDbRecordReceived (CaDbRecord &aRecord, const QByteArray &aSignature, const Hash &aFromNode) |
|
void | fillBucket (QList< SendQueueItem > &aSendQueue, const Hash &aStartOfBucket, const Hash &aEndOfBucket, quint32 aLastMutualConnectTime, const Hash &aForNode) |
|
| ModelBase (QString aDataTableName, unsigned aMaxRowsToKeep) |
|
| ~ModelBase () |
|
bool | setTimeLastReference (const Hash &aObjectFingerPrint, quint32 aTimeWhenLastReferenced) |
|
unsigned | getMaxRowsToKeep () |
|
void | setMaxRowsToKeep (unsigned aRows) |
|
void | truncateDataTableToMaxRows (void) |
|
void | updateDbTableRowCount () |
|
|
bool | doHandlepublishedOrSentRecord (CaDbRecord &aRecord, const QByteArray &aSignature, const QList< quint32 > &aBangPath, const Hash &aFromNode, bool aWasPublish) |
|
QString | persistDbRecordIntoDb (const CaDbRecord &aRecord, bool aIsNew, const QByteArray &aSignature, quint32 aReceivedFrom) |
|
QString | isRecordNew (const CaDbRecord &aRecord, bool *aResult, quint32 *aTimestampOfOldRecord=NULL) |
|
bool | tryVerifyRecord (CaDbRecord &aRecord, const QByteArray &aSignature, QList< QPair< Hash, Hash > > &aListOfGoodSignatures) |
|
void | deleteRecord (const Hash &aRecordId, const Hash &aSenderId) |
|
void | updateRecordVerification (const Hash &aRecordId, const Hash &aSenderId, bool aNewVerificationStatus) |
|
void | updateFTS (const CaDbRecord &aRecord, bool aIsNewRecord) |
|
This is is part of datamodel for storing database records.
Because classified ads is a distributed database that holds ads, profiles, private messages and profile comments, the same storage implementation can be extended to general-purpose database records. This is the implementation of local storage for those records. See CaDbRecord for records. This same API is available via TCL interface with different syntax but same concepts.
QList<CaDbRecord *> CaDbRecordModel::searchRecords |
( |
const Hash & |
aFromCollection, |
|
|
const Hash & |
aById = KNullHash , |
|
|
const quint32 |
aModifiedAfter = 0 , |
|
|
const quint32 |
aModifiedBefore = std::numeric_limits< quint32 >::max() , |
|
|
const qint64 |
aByHavingNumberMoreThan = std::numeric_limits< qint64 >::min() , |
|
|
const qint64 |
aByHavingNumberLessThan = std::numeric_limits< qint64 >::max() , |
|
|
const QString & |
aBySearchPhrase = QString::null , |
|
|
const Hash & |
aBySender = KNullHash , |
|
|
const bool |
aForPublish = false |
|
) |
| |
Method for retrieving db records. See CaDbRecord for records being fetched. Limiting criteria can be specified using several optional parameters. Those parameters are considered together using "AND" operation, meaning they all need to be satisfied at the same time for a record to be returned. For example, if both "by sender" and "modified after" parameters are given, result set contains only records from that given profile and whose publish time is after given time.
This may have a side-effect when search terms are broad (like, only collection specified) and it may be suspected that the search is not fully served what it comes to potential resultset, this method may give the query to DbRecordRetrievalEngine that will spam the network with the query. More records from neighboring network nodes fitting the search criteria may then start appearing into database. TCL app that originated the query will receive notifications about new records but it will still need to use this same method here to fetch contents of the new records. In particular, if record is queried using aById parameter and the record is found, then no network-query is started.
- Parameters
-
aFromCollection | Returns records whose CaDbRecord::iCollectionId match this parameter. Either this or aById argument must be given. Specifying only this will return whole collection that may be huge. |
aById | Returns record whose CaDbRecord::iRecordId matches. Result-set is either empty or contains one record. If user passes KNullHash here then value of this argument is simply ignored and search method will return records fitting criteria stated by other method arguments like aBySearchPhrase. In theory it is possible that 2 users end up publishing a record with same id but that should be fairly rare occasion. |
aModifiedAfter | Returns records that have last been modified after given time. Time of modification is stored in CaDbRecord::iTimeOfPublish. |
aModifiedBefore | Returns records that have last been modified before given time. |
aByHavingNumberMoreThan | Returns records whose CaDbRecord::iSearchNumber is more or equal than number given here. |
aByHavingNumberLessThan | Returns records whose CaDbRecord::iSearchNumber is less or equal than number given here. |
aBySearchPhrase | Returns records whose CaDbRecord::iSearchPhrase matches the string given here, according to rules of sqlite FTS string matching implementation. |
aBySender | Returns only records published by profile given in this argument. |
aForPublish | if set to true, data-parts of the records are returned un-altered from database. Normally records are de-crypted and un-compressed before getting returned but if record is meant to be sent to another node, the bitstream must be exactly the one that got signed. |
- Returns
- Pointer array of db records. Caller is responsible for deleting the returned records.