mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
initial work on note fulltext (schema changes, updating...)
This commit is contained in:
parent
05374becfd
commit
d25a1e3ed9
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<dataSource name="document.db">
|
||||
<database-model serializer="dbm" dbms="SQLITE" family-id="SQLITE" format-version="4.14">
|
||||
<database-model serializer="dbm" dbms="SQLITE" family-id="SQLITE" format-version="4.15">
|
||||
<root id="1">
|
||||
<ServerVersion>3.16.1</ServerVersion>
|
||||
</root>
|
||||
@ -17,661 +17,765 @@
|
||||
<table id="9" parent="2" name="event_log"/>
|
||||
<table id="10" parent="2" name="links"/>
|
||||
<table id="11" parent="2" name="note_contents"/>
|
||||
<table id="12" parent="2" name="note_revisions"/>
|
||||
<table id="13" parent="2" name="notes"/>
|
||||
<table id="14" parent="2" name="options"/>
|
||||
<table id="15" parent="2" name="recent_notes"/>
|
||||
<table id="16" parent="2" name="source_ids"/>
|
||||
<table id="17" parent="2" name="sqlite_master">
|
||||
<table id="12" parent="2" name="note_fulltext_config">
|
||||
<WithoutRowId>1</WithoutRowId>
|
||||
</table>
|
||||
<table id="13" parent="2" name="note_fulltext_content"/>
|
||||
<table id="14" parent="2" name="note_fulltext_data"/>
|
||||
<table id="15" parent="2" name="note_fulltext_docsize"/>
|
||||
<table id="16" parent="2" name="note_fulltext_idx">
|
||||
<WithoutRowId>1</WithoutRowId>
|
||||
</table>
|
||||
<table id="17" parent="2" name="note_revisions"/>
|
||||
<table id="18" parent="2" name="notes"/>
|
||||
<table id="19" parent="2" name="options"/>
|
||||
<table id="20" parent="2" name="recent_notes"/>
|
||||
<table id="21" parent="2" name="source_ids"/>
|
||||
<table id="22" parent="2" name="sqlite_master">
|
||||
<System>1</System>
|
||||
</table>
|
||||
<table id="18" parent="2" name="sqlite_sequence">
|
||||
<table id="23" parent="2" name="sqlite_sequence">
|
||||
<System>1</System>
|
||||
</table>
|
||||
<table id="19" parent="2" name="sync"/>
|
||||
<column id="20" parent="6" name="apiTokenId">
|
||||
<table id="24" parent="2" name="sync"/>
|
||||
<virtual-table id="25" parent="2" name="note_fulltext">
|
||||
<Module>fts5</Module>
|
||||
<Arguments>noteId UNINDEXED
|
||||
title
|
||||
titleHash UNINDEXED
|
||||
content
|
||||
contentHash UNINDEXED</Arguments>
|
||||
</virtual-table>
|
||||
<column id="26" parent="6" name="apiTokenId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="21" parent="6" name="token">
|
||||
<column id="27" parent="6" name="token">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="22" parent="6" name="dateCreated">
|
||||
<column id="28" parent="6" name="dateCreated">
|
||||
<Position>3</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="23" parent="6" name="isDeleted">
|
||||
<column id="29" parent="6" name="isDeleted">
|
||||
<Position>4</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="24" parent="6" name="hash">
|
||||
<column id="30" parent="6" name="hash">
|
||||
<Position>5</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<index id="25" parent="6" name="sqlite_autoindex_api_tokens_1">
|
||||
<index id="31" parent="6" name="sqlite_autoindex_api_tokens_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>apiTokenId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="26" parent="6">
|
||||
<key id="32" parent="6">
|
||||
<ColNames>apiTokenId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_api_tokens_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="27" parent="7" name="attributeId">
|
||||
<column id="33" parent="7" name="attributeId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="28" parent="7" name="noteId">
|
||||
<column id="34" parent="7" name="noteId">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="29" parent="7" name="type">
|
||||
<column id="35" parent="7" name="type">
|
||||
<Position>3</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="30" parent="7" name="name">
|
||||
<column id="36" parent="7" name="name">
|
||||
<Position>4</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="31" parent="7" name="value">
|
||||
<column id="37" parent="7" name="value">
|
||||
<Position>5</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>''</DefaultExpression>
|
||||
</column>
|
||||
<column id="32" parent="7" name="position">
|
||||
<column id="38" parent="7" name="position">
|
||||
<Position>6</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="33" parent="7" name="dateCreated">
|
||||
<column id="39" parent="7" name="dateCreated">
|
||||
<Position>7</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="34" parent="7" name="dateModified">
|
||||
<column id="40" parent="7" name="dateModified">
|
||||
<Position>8</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="35" parent="7" name="isDeleted">
|
||||
<column id="41" parent="7" name="isDeleted">
|
||||
<Position>9</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="36" parent="7" name="hash">
|
||||
<column id="42" parent="7" name="hash">
|
||||
<Position>10</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<column id="37" parent="7" name="isInheritable">
|
||||
<column id="43" parent="7" name="isInheritable">
|
||||
<Position>11</Position>
|
||||
<DataType>int|0s</DataType>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<index id="38" parent="7" name="sqlite_autoindex_attributes_1">
|
||||
<index id="44" parent="7" name="sqlite_autoindex_attributes_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>attributeId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<index id="39" parent="7" name="IDX_attributes_noteId_index">
|
||||
<index id="45" parent="7" name="IDX_attributes_noteId_index">
|
||||
<ColNames>noteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<index id="40" parent="7" name="IDX_attributes_name_value">
|
||||
<index id="46" parent="7" name="IDX_attributes_name_value">
|
||||
<ColNames>name
|
||||
value</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<index id="41" parent="7" name="IDX_attributes_name_index">
|
||||
<index id="47" parent="7" name="IDX_attributes_name_index">
|
||||
<ColNames>name</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<index id="42" parent="7" name="IDX_attributes_value_index">
|
||||
<index id="48" parent="7" name="IDX_attributes_value_index">
|
||||
<ColNames>value</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<key id="43" parent="7">
|
||||
<key id="49" parent="7">
|
||||
<ColNames>attributeId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_attributes_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="44" parent="8" name="branchId">
|
||||
<column id="50" parent="8" name="branchId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="45" parent="8" name="noteId">
|
||||
<column id="51" parent="8" name="noteId">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="46" parent="8" name="parentNoteId">
|
||||
<column id="52" parent="8" name="parentNoteId">
|
||||
<Position>3</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="47" parent="8" name="notePosition">
|
||||
<column id="53" parent="8" name="notePosition">
|
||||
<Position>4</Position>
|
||||
<DataType>INTEGER|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="48" parent="8" name="prefix">
|
||||
<column id="54" parent="8" name="prefix">
|
||||
<Position>5</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
</column>
|
||||
<column id="49" parent="8" name="isExpanded">
|
||||
<column id="55" parent="8" name="isExpanded">
|
||||
<Position>6</Position>
|
||||
<DataType>BOOLEAN|0s</DataType>
|
||||
</column>
|
||||
<column id="50" parent="8" name="isDeleted">
|
||||
<column id="56" parent="8" name="isDeleted">
|
||||
<Position>7</Position>
|
||||
<DataType>INTEGER|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="51" parent="8" name="dateModified">
|
||||
<column id="57" parent="8" name="dateModified">
|
||||
<Position>8</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="52" parent="8" name="hash">
|
||||
<column id="58" parent="8" name="hash">
|
||||
<Position>9</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<column id="53" parent="8" name="dateCreated">
|
||||
<column id="59" parent="8" name="dateCreated">
|
||||
<Position>10</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>'1970-01-01T00:00:00.000Z'</DefaultExpression>
|
||||
</column>
|
||||
<index id="54" parent="8" name="sqlite_autoindex_branches_1">
|
||||
<index id="60" parent="8" name="sqlite_autoindex_branches_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>branchId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<index id="55" parent="8" name="IDX_branches_noteId_parentNoteId">
|
||||
<index id="61" parent="8" name="IDX_branches_noteId_parentNoteId">
|
||||
<ColNames>noteId
|
||||
parentNoteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<index id="56" parent="8" name="IDX_branches_noteId">
|
||||
<index id="62" parent="8" name="IDX_branches_noteId">
|
||||
<ColNames>noteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<index id="57" parent="8" name="IDX_branches_parentNoteId">
|
||||
<index id="63" parent="8" name="IDX_branches_parentNoteId">
|
||||
<ColNames>parentNoteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<key id="58" parent="8">
|
||||
<key id="64" parent="8">
|
||||
<ColNames>branchId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_branches_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="59" parent="9" name="eventId">
|
||||
<column id="65" parent="9" name="eventId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="60" parent="9" name="noteId">
|
||||
<column id="66" parent="9" name="noteId">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
</column>
|
||||
<column id="61" parent="9" name="comment">
|
||||
<column id="67" parent="9" name="comment">
|
||||
<Position>3</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
</column>
|
||||
<column id="62" parent="9" name="dateCreated">
|
||||
<column id="68" parent="9" name="dateCreated">
|
||||
<Position>4</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<index id="63" parent="9" name="sqlite_autoindex_event_log_1">
|
||||
<index id="69" parent="9" name="sqlite_autoindex_event_log_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>eventId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="64" parent="9">
|
||||
<key id="70" parent="9">
|
||||
<ColNames>eventId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_event_log_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="65" parent="10" name="linkId">
|
||||
<column id="71" parent="10" name="linkId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="66" parent="10" name="noteId">
|
||||
<column id="72" parent="10" name="noteId">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="67" parent="10" name="targetNoteId">
|
||||
<column id="73" parent="10" name="targetNoteId">
|
||||
<Position>3</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="68" parent="10" name="type">
|
||||
<column id="74" parent="10" name="type">
|
||||
<Position>4</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="69" parent="10" name="hash">
|
||||
<column id="75" parent="10" name="hash">
|
||||
<Position>5</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<column id="70" parent="10" name="isDeleted">
|
||||
<column id="76" parent="10" name="isDeleted">
|
||||
<Position>6</Position>
|
||||
<DataType>INTEGER|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="71" parent="10" name="dateCreated">
|
||||
<column id="77" parent="10" name="dateCreated">
|
||||
<Position>7</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="72" parent="10" name="dateModified">
|
||||
<column id="78" parent="10" name="dateModified">
|
||||
<Position>8</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<index id="73" parent="10" name="sqlite_autoindex_links_1">
|
||||
<index id="79" parent="10" name="sqlite_autoindex_links_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>linkId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<index id="74" parent="10" name="IDX_links_noteId_index">
|
||||
<index id="80" parent="10" name="IDX_links_noteId_index">
|
||||
<ColNames>noteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<index id="75" parent="10" name="IDX_links_targetNoteId_index">
|
||||
<index id="81" parent="10" name="IDX_links_targetNoteId_index">
|
||||
<ColNames>targetNoteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<key id="76" parent="10">
|
||||
<key id="82" parent="10">
|
||||
<ColNames>linkId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_links_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="77" parent="11" name="noteContentId">
|
||||
<column id="83" parent="11" name="noteContentId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="78" parent="11" name="noteId">
|
||||
<column id="84" parent="11" name="noteId">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="79" parent="11" name="isProtected">
|
||||
<column id="85" parent="11" name="isProtected">
|
||||
<Position>3</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="80" parent="11" name="content">
|
||||
<column id="86" parent="11" name="content">
|
||||
<Position>4</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<DefaultExpression>NULL</DefaultExpression>
|
||||
</column>
|
||||
<column id="81" parent="11" name="hash">
|
||||
<column id="87" parent="11" name="hash">
|
||||
<Position>5</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<column id="82" parent="11" name="dateCreated">
|
||||
<column id="88" parent="11" name="dateCreated">
|
||||
<Position>6</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>'2018-05-08T23:41:15.225Z'</DefaultExpression>
|
||||
</column>
|
||||
<column id="83" parent="11" name="dateModified">
|
||||
<column id="89" parent="11" name="dateModified">
|
||||
<Position>7</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>'2018-05-08T23:41:15.225Z'</DefaultExpression>
|
||||
</column>
|
||||
<index id="84" parent="11" name="sqlite_autoindex_note_contents_1">
|
||||
<index id="90" parent="11" name="sqlite_autoindex_note_contents_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>noteContentId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<index id="85" parent="11" name="IDX_note_contents_noteId">
|
||||
<index id="91" parent="11" name="IDX_note_contents_noteId">
|
||||
<ColNames>noteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="86" parent="11">
|
||||
<key id="92" parent="11">
|
||||
<ColNames>noteContentId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_note_contents_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="87" parent="12" name="noteRevisionId">
|
||||
<column id="93" parent="12" name="k">
|
||||
<Position>1</Position>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="94" parent="12" name="v">
|
||||
<Position>2</Position>
|
||||
</column>
|
||||
<index id="95" parent="12" name="sqlite_autoindex_note_fulltext_config_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>k</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="96" parent="12">
|
||||
<ColNames>k</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_note_fulltext_config_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="97" parent="13" name="id">
|
||||
<Position>1</Position>
|
||||
<DataType>INTEGER|0s</DataType>
|
||||
</column>
|
||||
<column id="98" parent="13" name="c0">
|
||||
<Position>2</Position>
|
||||
</column>
|
||||
<column id="99" parent="13" name="c1">
|
||||
<Position>3</Position>
|
||||
</column>
|
||||
<column id="100" parent="13" name="c2">
|
||||
<Position>4</Position>
|
||||
</column>
|
||||
<column id="101" parent="13" name="c3">
|
||||
<Position>5</Position>
|
||||
</column>
|
||||
<column id="102" parent="13" name="c4">
|
||||
<Position>6</Position>
|
||||
</column>
|
||||
<key id="103" parent="13">
|
||||
<ColNames>id</ColNames>
|
||||
<Primary>1</Primary>
|
||||
</key>
|
||||
<column id="104" parent="14" name="id">
|
||||
<Position>1</Position>
|
||||
<DataType>INTEGER|0s</DataType>
|
||||
</column>
|
||||
<column id="105" parent="14" name="block">
|
||||
<Position>2</Position>
|
||||
<DataType>BLOB|0s</DataType>
|
||||
</column>
|
||||
<key id="106" parent="14">
|
||||
<ColNames>id</ColNames>
|
||||
<Primary>1</Primary>
|
||||
</key>
|
||||
<column id="107" parent="15" name="id">
|
||||
<Position>1</Position>
|
||||
<DataType>INTEGER|0s</DataType>
|
||||
</column>
|
||||
<column id="108" parent="15" name="sz">
|
||||
<Position>2</Position>
|
||||
<DataType>BLOB|0s</DataType>
|
||||
</column>
|
||||
<key id="109" parent="15">
|
||||
<ColNames>id</ColNames>
|
||||
<Primary>1</Primary>
|
||||
</key>
|
||||
<column id="110" parent="16" name="segid">
|
||||
<Position>1</Position>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="111" parent="16" name="term">
|
||||
<Position>2</Position>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="112" parent="16" name="pgno">
|
||||
<Position>3</Position>
|
||||
</column>
|
||||
<index id="113" parent="16" name="sqlite_autoindex_note_fulltext_idx_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>segid
|
||||
term</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="114" parent="16">
|
||||
<ColNames>segid
|
||||
term</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_note_fulltext_idx_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="115" parent="17" name="noteRevisionId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="88" parent="12" name="noteId">
|
||||
<column id="116" parent="17" name="noteId">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="89" parent="12" name="title">
|
||||
<column id="117" parent="17" name="title">
|
||||
<Position>3</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
</column>
|
||||
<column id="90" parent="12" name="content">
|
||||
<column id="118" parent="17" name="content">
|
||||
<Position>4</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
</column>
|
||||
<column id="91" parent="12" name="isProtected">
|
||||
<column id="119" parent="17" name="isProtected">
|
||||
<Position>5</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="92" parent="12" name="dateModifiedFrom">
|
||||
<column id="120" parent="17" name="dateModifiedFrom">
|
||||
<Position>6</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="93" parent="12" name="dateModifiedTo">
|
||||
<column id="121" parent="17" name="dateModifiedTo">
|
||||
<Position>7</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="94" parent="12" name="type">
|
||||
<column id="122" parent="17" name="type">
|
||||
<Position>8</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>''</DefaultExpression>
|
||||
</column>
|
||||
<column id="95" parent="12" name="mime">
|
||||
<column id="123" parent="17" name="mime">
|
||||
<Position>9</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>''</DefaultExpression>
|
||||
</column>
|
||||
<column id="96" parent="12" name="hash">
|
||||
<column id="124" parent="17" name="hash">
|
||||
<Position>10</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<index id="97" parent="12" name="sqlite_autoindex_note_revisions_1">
|
||||
<index id="125" parent="17" name="sqlite_autoindex_note_revisions_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>noteRevisionId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<index id="98" parent="12" name="IDX_note_revisions_noteId">
|
||||
<index id="126" parent="17" name="IDX_note_revisions_noteId">
|
||||
<ColNames>noteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<index id="99" parent="12" name="IDX_note_revisions_dateModifiedFrom">
|
||||
<index id="127" parent="17" name="IDX_note_revisions_dateModifiedFrom">
|
||||
<ColNames>dateModifiedFrom</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<index id="100" parent="12" name="IDX_note_revisions_dateModifiedTo">
|
||||
<index id="128" parent="17" name="IDX_note_revisions_dateModifiedTo">
|
||||
<ColNames>dateModifiedTo</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<key id="101" parent="12">
|
||||
<key id="129" parent="17">
|
||||
<ColNames>noteRevisionId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_note_revisions_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="102" parent="13" name="noteId">
|
||||
<column id="130" parent="18" name="noteId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="103" parent="13" name="title">
|
||||
<column id="131" parent="18" name="title">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>"note"</DefaultExpression>
|
||||
</column>
|
||||
<column id="104" parent="13" name="isProtected">
|
||||
<column id="132" parent="18" name="isProtected">
|
||||
<Position>3</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="105" parent="13" name="type">
|
||||
<column id="133" parent="18" name="type">
|
||||
<Position>4</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>'text'</DefaultExpression>
|
||||
</column>
|
||||
<column id="106" parent="13" name="mime">
|
||||
<column id="134" parent="18" name="mime">
|
||||
<Position>5</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>'text/html'</DefaultExpression>
|
||||
</column>
|
||||
<column id="107" parent="13" name="hash">
|
||||
<column id="135" parent="18" name="hash">
|
||||
<Position>6</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<column id="108" parent="13" name="isDeleted">
|
||||
<column id="136" parent="18" name="isDeleted">
|
||||
<Position>7</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="109" parent="13" name="dateCreated">
|
||||
<column id="137" parent="18" name="dateCreated">
|
||||
<Position>8</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="110" parent="13" name="dateModified">
|
||||
<column id="138" parent="18" name="dateModified">
|
||||
<Position>9</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<index id="111" parent="13" name="sqlite_autoindex_notes_1">
|
||||
<index id="139" parent="18" name="sqlite_autoindex_notes_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>noteId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="112" parent="13">
|
||||
<key id="140" parent="18">
|
||||
<ColNames>noteId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_notes_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="113" parent="14" name="name">
|
||||
<column id="141" parent="19" name="name">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="114" parent="14" name="value">
|
||||
<column id="142" parent="19" name="value">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
</column>
|
||||
<column id="115" parent="14" name="dateModified">
|
||||
<column id="143" parent="19" name="dateModified">
|
||||
<Position>3</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
</column>
|
||||
<column id="116" parent="14" name="isSynced">
|
||||
<column id="144" parent="19" name="isSynced">
|
||||
<Position>4</Position>
|
||||
<DataType>INTEGER|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>0</DefaultExpression>
|
||||
</column>
|
||||
<column id="117" parent="14" name="hash">
|
||||
<column id="145" parent="19" name="hash">
|
||||
<Position>5</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<column id="118" parent="14" name="dateCreated">
|
||||
<column id="146" parent="19" name="dateCreated">
|
||||
<Position>6</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>'1970-01-01T00:00:00.000Z'</DefaultExpression>
|
||||
</column>
|
||||
<index id="119" parent="14" name="sqlite_autoindex_options_1">
|
||||
<index id="147" parent="19" name="sqlite_autoindex_options_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>name</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="120" parent="14">
|
||||
<key id="148" parent="19">
|
||||
<ColNames>name</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_options_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="121" parent="15" name="branchId">
|
||||
<column id="149" parent="20" name="branchId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="122" parent="15" name="notePath">
|
||||
<column id="150" parent="20" name="notePath">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="123" parent="15" name="hash">
|
||||
<column id="151" parent="20" name="hash">
|
||||
<Position>3</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<DefaultExpression>""</DefaultExpression>
|
||||
</column>
|
||||
<column id="124" parent="15" name="dateCreated">
|
||||
<column id="152" parent="20" name="dateCreated">
|
||||
<Position>4</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="125" parent="15" name="isDeleted">
|
||||
<column id="153" parent="20" name="isDeleted">
|
||||
<Position>5</Position>
|
||||
<DataType>INT|0s</DataType>
|
||||
</column>
|
||||
<index id="126" parent="15" name="sqlite_autoindex_recent_notes_1">
|
||||
<index id="154" parent="20" name="sqlite_autoindex_recent_notes_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>branchId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="127" parent="15">
|
||||
<key id="155" parent="20">
|
||||
<ColNames>branchId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_recent_notes_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="128" parent="16" name="sourceId">
|
||||
<column id="156" parent="21" name="sourceId">
|
||||
<Position>1</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="129" parent="16" name="dateCreated">
|
||||
<column id="157" parent="21" name="dateCreated">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<index id="130" parent="16" name="sqlite_autoindex_source_ids_1">
|
||||
<index id="158" parent="21" name="sqlite_autoindex_source_ids_1">
|
||||
<NameSurrogate>1</NameSurrogate>
|
||||
<ColNames>sourceId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<key id="131" parent="16">
|
||||
<key id="159" parent="21">
|
||||
<ColNames>sourceId</ColNames>
|
||||
<Primary>1</Primary>
|
||||
<UnderlyingIndexName>sqlite_autoindex_source_ids_1</UnderlyingIndexName>
|
||||
</key>
|
||||
<column id="132" parent="17" name="type">
|
||||
<column id="160" parent="22" name="type">
|
||||
<Position>1</Position>
|
||||
<DataType>text|0s</DataType>
|
||||
</column>
|
||||
<column id="133" parent="17" name="name">
|
||||
<column id="161" parent="22" name="name">
|
||||
<Position>2</Position>
|
||||
<DataType>text|0s</DataType>
|
||||
</column>
|
||||
<column id="134" parent="17" name="tbl_name">
|
||||
<column id="162" parent="22" name="tbl_name">
|
||||
<Position>3</Position>
|
||||
<DataType>text|0s</DataType>
|
||||
</column>
|
||||
<column id="135" parent="17" name="rootpage">
|
||||
<column id="163" parent="22" name="rootpage">
|
||||
<Position>4</Position>
|
||||
<DataType>integer|0s</DataType>
|
||||
</column>
|
||||
<column id="136" parent="17" name="sql">
|
||||
<column id="164" parent="22" name="sql">
|
||||
<Position>5</Position>
|
||||
<DataType>text|0s</DataType>
|
||||
</column>
|
||||
<column id="137" parent="18" name="name">
|
||||
<column id="165" parent="23" name="name">
|
||||
<Position>1</Position>
|
||||
</column>
|
||||
<column id="138" parent="18" name="seq">
|
||||
<column id="166" parent="23" name="seq">
|
||||
<Position>2</Position>
|
||||
</column>
|
||||
<column id="139" parent="19" name="id">
|
||||
<column id="167" parent="24" name="id">
|
||||
<Position>1</Position>
|
||||
<DataType>INTEGER|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
<SequenceIdentity>1</SequenceIdentity>
|
||||
</column>
|
||||
<column id="140" parent="19" name="entityName">
|
||||
<column id="168" parent="24" name="entityName">
|
||||
<Position>2</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="141" parent="19" name="entityId">
|
||||
<column id="169" parent="24" name="entityId">
|
||||
<Position>3</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="142" parent="19" name="sourceId">
|
||||
<column id="170" parent="24" name="sourceId">
|
||||
<Position>4</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<column id="143" parent="19" name="syncDate">
|
||||
<column id="171" parent="24" name="syncDate">
|
||||
<Position>5</Position>
|
||||
<DataType>TEXT|0s</DataType>
|
||||
<NotNull>1</NotNull>
|
||||
</column>
|
||||
<index id="144" parent="19" name="IDX_sync_entityName_entityId">
|
||||
<index id="172" parent="24" name="IDX_sync_entityName_entityId">
|
||||
<ColNames>entityName
|
||||
entityId</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
<Unique>1</Unique>
|
||||
</index>
|
||||
<index id="145" parent="19" name="IDX_sync_syncDate">
|
||||
<index id="173" parent="24" name="IDX_sync_syncDate">
|
||||
<ColNames>syncDate</ColNames>
|
||||
<ColumnCollations></ColumnCollations>
|
||||
</index>
|
||||
<key id="146" parent="19">
|
||||
<key id="174" parent="24">
|
||||
<ColNames>id</ColNames>
|
||||
<Primary>1</Primary>
|
||||
</key>
|
||||
|
1
db/migrations/0127__add_note_fulltext.sql
Normal file
1
db/migrations/0127__add_note_fulltext.sql
Normal file
@ -0,0 +1 @@
|
||||
CREATE VIRTUAL TABLE note_fulltext USING fts5(noteId UNINDEXED, title, titleHash UNINDEXED, content, contentHash UNINDEXED);
|
10
db/migrations/0128__fill_note_fulltext.js
Normal file
10
db/migrations/0128__fill_note_fulltext.js
Normal file
@ -0,0 +1,10 @@
|
||||
const repository = require('../../src/services/repository');
|
||||
const noteFulltextService = require('../../src/services/note_fulltext');
|
||||
|
||||
module.exports = async () => {
|
||||
const notes = await repository.getEntities('SELECT * FROM notes WHERE isDeleted = 0 AND isProtected = 0');
|
||||
|
||||
for (const note of notes) {
|
||||
await noteFulltextService.updateNoteFulltext(note);
|
||||
}
|
||||
};
|
136
package-lock.json
generated
136
package-lock.json
generated
@ -430,8 +430,7 @@
|
||||
"@types/node": {
|
||||
"version": "10.12.21",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.21.tgz",
|
||||
"integrity": "sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ=="
|
||||
},
|
||||
"abab": {
|
||||
"version": "2.0.0",
|
||||
@ -1111,6 +1110,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"boolbase": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||
},
|
||||
"boxen": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/boxen/-/boxen-1.3.0.tgz",
|
||||
@ -1563,6 +1567,29 @@
|
||||
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
|
||||
"dev": true
|
||||
},
|
||||
"cheerio": {
|
||||
"version": "1.0.0-rc.2",
|
||||
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.2.tgz",
|
||||
"integrity": "sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs=",
|
||||
"requires": {
|
||||
"css-select": "~1.2.0",
|
||||
"dom-serializer": "~0.1.0",
|
||||
"entities": "~1.1.1",
|
||||
"htmlparser2": "^3.9.1",
|
||||
"lodash": "^4.15.0",
|
||||
"parse5": "^3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"parse5": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz",
|
||||
"integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==",
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"chownr": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz",
|
||||
@ -1994,6 +2021,22 @@
|
||||
"integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=",
|
||||
"dev": true
|
||||
},
|
||||
"css-select": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz",
|
||||
"integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=",
|
||||
"requires": {
|
||||
"boolbase": "~1.0.0",
|
||||
"css-what": "2.1",
|
||||
"domutils": "1.5.1",
|
||||
"nth-check": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"css-what": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz",
|
||||
"integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg=="
|
||||
},
|
||||
"cssom": {
|
||||
"version": "0.3.4",
|
||||
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.4.tgz",
|
||||
@ -2514,11 +2557,25 @@
|
||||
"esutils": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"dom-serializer": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz",
|
||||
"integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==",
|
||||
"requires": {
|
||||
"domelementtype": "^1.3.0",
|
||||
"entities": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"dom-walk": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz",
|
||||
"integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg="
|
||||
},
|
||||
"domelementtype": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz",
|
||||
"integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w=="
|
||||
},
|
||||
"domexception": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz",
|
||||
@ -2527,6 +2584,23 @@
|
||||
"webidl-conversions": "^4.0.2"
|
||||
}
|
||||
},
|
||||
"domhandler": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz",
|
||||
"integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==",
|
||||
"requires": {
|
||||
"domelementtype": "1"
|
||||
}
|
||||
},
|
||||
"domutils": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz",
|
||||
"integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=",
|
||||
"requires": {
|
||||
"dom-serializer": "0",
|
||||
"domelementtype": "1"
|
||||
}
|
||||
},
|
||||
"dont-sniff-mimetype": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dont-sniff-mimetype/-/dont-sniff-mimetype-1.0.0.tgz",
|
||||
@ -5470,6 +5544,11 @@
|
||||
"integrity": "sha1-ieJdtgS3Jcj1l2//Ct3JIbgopac=",
|
||||
"dev": true
|
||||
},
|
||||
"he": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
|
||||
},
|
||||
"helmet": {
|
||||
"version": "3.15.1",
|
||||
"resolved": "https://registry.npmjs.org/helmet/-/helmet-3.15.1.tgz",
|
||||
@ -5557,6 +5636,41 @@
|
||||
"whatwg-encoding": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"html2plaintext": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/html2plaintext/-/html2plaintext-2.1.2.tgz",
|
||||
"integrity": "sha512-/7rk161q0RFtQhu0F7oU7MFUtqjm2qBrVfoS8EOaHSdRNt72CNNYSV1/wN+TfO2GhgLQdIjPctmiWPX3oRcNFQ==",
|
||||
"requires": {
|
||||
"cheerio": "1.0.0-rc.2",
|
||||
"he": "1.2.0",
|
||||
"plumb": "0.1.0"
|
||||
}
|
||||
},
|
||||
"htmlparser2": {
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz",
|
||||
"integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==",
|
||||
"requires": {
|
||||
"domelementtype": "^1.3.1",
|
||||
"domhandler": "^2.3.0",
|
||||
"domutils": "^1.5.1",
|
||||
"entities": "^1.1.1",
|
||||
"inherits": "^2.0.1",
|
||||
"readable-stream": "^3.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"readable-stream": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz",
|
||||
"integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==",
|
||||
"requires": {
|
||||
"inherits": "^2.0.3",
|
||||
"string_decoder": "^1.1.1",
|
||||
"util-deprecate": "^1.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"http-cache-semantics": {
|
||||
"version": "3.8.1",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz",
|
||||
@ -8038,6 +8152,14 @@
|
||||
"set-blocking": "~2.0.0"
|
||||
}
|
||||
},
|
||||
"nth-check": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
|
||||
"integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==",
|
||||
"requires": {
|
||||
"boolbase": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"nugget": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/nugget/-/nugget-2.0.1.tgz",
|
||||
@ -8771,6 +8893,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"plumb": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/plumb/-/plumb-0.1.0.tgz",
|
||||
"integrity": "sha1-TFd5ClCWkoMv2/EN+t3XlIxctXQ="
|
||||
},
|
||||
"plur": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/plur/-/plur-3.0.1.tgz",
|
||||
@ -10850,6 +10977,11 @@
|
||||
"escape-string-regexp": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"striptags": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/striptags/-/striptags-3.1.1.tgz",
|
||||
"integrity": "sha1-yMPn/db7S7OjKjt1LltePjgJPr0="
|
||||
},
|
||||
"sum-up": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sum-up/-/sum-up-1.0.3.tgz",
|
||||
|
@ -41,6 +41,7 @@
|
||||
"get-port": "4.2.0",
|
||||
"helmet": "3.15.1",
|
||||
"html": "1.0.0",
|
||||
"html2plaintext": "^2.1.2",
|
||||
"image-type": "3.0.0",
|
||||
"imagemin": "6.1.0",
|
||||
"imagemin-giflossy": "5.1.10",
|
||||
|
@ -7,6 +7,7 @@ const protectedSessionService = require('../services/protected_session');
|
||||
const repository = require('../services/repository');
|
||||
const sql = require('../services/sql');
|
||||
const dateUtils = require('../services/date_utils');
|
||||
const noteFulltextService = require('../services/note_fulltext');
|
||||
|
||||
const LABEL = 'label';
|
||||
const LABEL_DEFINITION = 'label-definition';
|
||||
@ -687,6 +688,10 @@ class Note extends Entity {
|
||||
delete pojo.titleCipherText;
|
||||
delete pojo.noteContent;
|
||||
}
|
||||
|
||||
async afterSaving() {
|
||||
noteFulltextService.triggerNoteFulltextUpdate(this.noteId);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Note;
|
@ -4,6 +4,7 @@ const Entity = require('./entity');
|
||||
const protectedSessionService = require('../services/protected_session');
|
||||
const repository = require('../services/repository');
|
||||
const dateUtils = require('../services/date_utils');
|
||||
const noteFulltextService = require('../services/note_fulltext');
|
||||
|
||||
/**
|
||||
* This represents a Note which is a central object in the Trilium Notes project.
|
||||
@ -91,6 +92,10 @@ class NoteContent extends Entity {
|
||||
delete pojo.isContentAvailable;
|
||||
delete pojo.contentCipherText;
|
||||
}
|
||||
|
||||
async afterSaving() {
|
||||
noteFulltextService.triggerNoteFulltextUpdate(this.noteId);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NoteContent;
|
@ -4,8 +4,8 @@ const build = require('./build');
|
||||
const packageJson = require('../../package');
|
||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||
|
||||
const APP_DB_VERSION = 126;
|
||||
const SYNC_VERSION = 6;
|
||||
const APP_DB_VERSION = 128;
|
||||
const SYNC_VERSION = 7;
|
||||
|
||||
module.exports = {
|
||||
appVersion: packageJson.version,
|
||||
|
60
src/services/note_fulltext.js
Normal file
60
src/services/note_fulltext.js
Normal file
@ -0,0 +1,60 @@
|
||||
const sql = require('./sql');
|
||||
const repository = require('./repository');
|
||||
const html2plaintext = require('html2plaintext');
|
||||
|
||||
const noteIdQueue = [];
|
||||
|
||||
async function updateNoteFulltext(note) {
|
||||
if (note.isDeleted || note.isProtected || note.hasLabel('archived')) {
|
||||
await sql.execute(`DELETE
|
||||
FROM note_fulltext
|
||||
WHERE noteId = ?`, [note.noteId]);
|
||||
} else {
|
||||
let content = null;
|
||||
let contentHash = null;
|
||||
|
||||
if (['text', 'code'].includes(note.type)) {
|
||||
const noteContent = await note.getNoteContent();
|
||||
content = noteContent.content;
|
||||
|
||||
if (note.type === 'text' && note.mime === 'text/html') {
|
||||
content = html2plaintext(content);
|
||||
}
|
||||
|
||||
contentHash = noteContent.hash;
|
||||
}
|
||||
|
||||
// optimistically try to update first ...
|
||||
const res = await sql.execute(`UPDATE note_fulltext title = ?, titleHash = ?, content = ?, contentHash = ? WHERE noteId = ?`, [note.title, note.hash, content, contentHash, note.noteId]);
|
||||
|
||||
// ... and insert only when the update did not work
|
||||
if (res.stmt.changes === 0) {
|
||||
await sql.execute(`INSERT INTO note_fulltext (title, titleHash, content, contentHash, noteId)
|
||||
VALUES (?, ?, ?, ?, ?)`, [note.title, note.hash, content, contentHash, note.noteId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function triggerNoteFulltextUpdate(noteId) {
|
||||
if (!noteIdQueue.includes(noteId)) {
|
||||
noteIdQueue.push(noteId);
|
||||
}
|
||||
|
||||
while (noteIdQueue.length > 0) {
|
||||
await sql.transactional(async () => {
|
||||
if (noteIdQueue.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const noteId = noteIdQueue.shift();
|
||||
const note = await repository.getNote(noteId);
|
||||
|
||||
await updateNoteFulltext(note);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
triggerNoteFulltextUpdate,
|
||||
updateNoteFulltext
|
||||
};
|
@ -126,6 +126,10 @@ async function updateEntity(entity) {
|
||||
await eventService.emit(entity.isDeleted ? eventService.ENTITY_DELETED : eventService.ENTITY_CHANGED, eventPayload);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.afterSaving) {
|
||||
await entity.afterSaving();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ const log = require('./log');
|
||||
const eventLogService = require('./event_log');
|
||||
const syncTableService = require('./sync_table');
|
||||
const eventService = require('./events');
|
||||
const noteFulltextService = require('../services/note_fulltext');
|
||||
|
||||
async function updateEntity(sync, entity, sourceId) {
|
||||
const {entityName} = sync;
|
||||
@ -61,6 +62,8 @@ async function updateNote(entity, sourceId) {
|
||||
await syncTableService.addNoteSync(entity.noteId, sourceId);
|
||||
});
|
||||
|
||||
noteFulltextService.triggerNoteFulltextUpdate(entity.noteId);
|
||||
|
||||
log.info("Update/sync note " + entity.noteId);
|
||||
}
|
||||
}
|
||||
@ -75,6 +78,8 @@ async function updateNoteContent(entity, sourceId) {
|
||||
await sql.replace("note_contents", entity);
|
||||
|
||||
await syncTableService.addNoteContentSync(entity.noteContentId, sourceId);
|
||||
|
||||
noteFulltextService.triggerNoteFulltextUpdate(entity.noteId);
|
||||
});
|
||||
|
||||
log.info("Update/sync note content " + entity.noteContentId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user