mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-12-01 07:37:18 +01:00
Add database tables to tag notes
This commit is contained in:
@@ -68,6 +68,69 @@
|
|||||||
</field>
|
</field>
|
||||||
</declaration>
|
</declaration>
|
||||||
</table>
|
</table>
|
||||||
|
<table>
|
||||||
|
<name>*dbprefix*quicknotes_tags</name>
|
||||||
|
<declaration>
|
||||||
|
<field>
|
||||||
|
<name>id</name>
|
||||||
|
<type>integer</type>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<autoincrement>true</autoincrement>
|
||||||
|
<unsigned>true</unsigned>
|
||||||
|
<primary>true</primary>
|
||||||
|
<length>8</length>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>user_id</name>
|
||||||
|
<type>text</type>
|
||||||
|
<length>200</length>
|
||||||
|
<default></default>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>name</name>
|
||||||
|
<type>text</type>
|
||||||
|
<length>200</length>
|
||||||
|
<default></default>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
</field>
|
||||||
|
</declaration>
|
||||||
|
</table>
|
||||||
|
<table>
|
||||||
|
<name>*dbprefix*quicknotes_note_tags</name>
|
||||||
|
<declaration>
|
||||||
|
<field>
|
||||||
|
<name>id</name>
|
||||||
|
<type>integer</type>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<autoincrement>true</autoincrement>
|
||||||
|
<unsigned>true</unsigned>
|
||||||
|
<primary>true</primary>
|
||||||
|
<length>8</length>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>user_id</name>
|
||||||
|
<type>text</type>
|
||||||
|
<length>200</length>
|
||||||
|
<default></default>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>note_id</name>
|
||||||
|
<type>integer</type>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<unsigned>true</unsigned>
|
||||||
|
<length>8</length>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>tag_id</name>
|
||||||
|
<type>integer</type>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<unsigned>true</unsigned>
|
||||||
|
<length>8</length>
|
||||||
|
</field>
|
||||||
|
</declaration>
|
||||||
|
</table>
|
||||||
<table>
|
<table>
|
||||||
<name>*dbprefix*quicknotes_tasks</name>
|
<name>*dbprefix*quicknotes_tasks</name>
|
||||||
<declaration>
|
<declaration>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<name>Quick notes</name>
|
<name>Quick notes</name>
|
||||||
<summary>Quick notes with a basic rich text</summary>
|
<summary>Quick notes with a basic rich text</summary>
|
||||||
<description>Quick notes with a basic rich text</description>
|
<description>Quick notes with a basic rich text</description>
|
||||||
<version>0.1.10</version>
|
<version>0.1.11</version>
|
||||||
<licence>agpl</licence>
|
<licence>agpl</licence>
|
||||||
<author>Matias De lellis</author>
|
<author>Matias De lellis</author>
|
||||||
<namespace>QuickNotes</namespace>
|
<namespace>QuickNotes</namespace>
|
||||||
|
|||||||
23
db/notetag.php
Normal file
23
db/notetag.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
namespace OCA\QuickNotes\Db;
|
||||||
|
|
||||||
|
use JsonSerializable;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
|
||||||
|
class NoteTag extends Entity implements JsonSerializable {
|
||||||
|
|
||||||
|
protected $noteId;
|
||||||
|
protected $tagId
|
||||||
|
protected $userId;
|
||||||
|
|
||||||
|
public function jsonSerialize() {
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'noteid' => $this->noteId,
|
||||||
|
'tagid' => $this->tagId,
|
||||||
|
'userid' => $this->userId
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
23
db/notetagmapper.php
Normal file
23
db/notetagmapper.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
namespace OCA\QuickNotes\Db;
|
||||||
|
|
||||||
|
use OCP\IDBConnection;
|
||||||
|
use OCP\AppFramework\Db\Mapper;
|
||||||
|
|
||||||
|
class NoteTagMapper extends Mapper {
|
||||||
|
|
||||||
|
public function __construct(IDBConnection $db) {
|
||||||
|
parent::__construct($db, 'quicknotes_note_tags', '\OCA\QuickNotes\Db\Tag');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function find($id, $userId) {
|
||||||
|
$sql = 'SELECT * FROM *PREFIX*quicknotes_note_tags WHERE id = ? AND user_id = ?';
|
||||||
|
return $this->findEntity($sql, [$id, $userId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAll($userId) {
|
||||||
|
$sql = 'SELECT * FROM *PREFIX*quicknotes_note_tags WHERE user_id = ?';
|
||||||
|
return $this->findEntities($sql, [$userId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
21
db/tag.php
Normal file
21
db/tag.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace OCA\QuickNotes\Db;
|
||||||
|
|
||||||
|
use JsonSerializable;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
|
||||||
|
class Tag extends Entity implements JsonSerializable {
|
||||||
|
|
||||||
|
protected $name;
|
||||||
|
protected $userId;
|
||||||
|
|
||||||
|
public function jsonSerialize() {
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'userid' => $this->userId
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
23
db/tagmapper.php
Normal file
23
db/tagmapper.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
namespace OCA\QuickNotes\Db;
|
||||||
|
|
||||||
|
use OCP\IDBConnection;
|
||||||
|
use OCP\AppFramework\Db\Mapper;
|
||||||
|
|
||||||
|
class TagMapper extends Mapper {
|
||||||
|
|
||||||
|
public function __construct(IDBConnection $db) {
|
||||||
|
parent::__construct($db, 'quicknotes_tags', '\OCA\QuickNotes\Db\Tag');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function find($id, $userId) {
|
||||||
|
$sql = 'SELECT * FROM *PREFIX*quicknotes_tags WHERE id = ? AND user_id = ?';
|
||||||
|
return $this->findEntity($sql, [$id, $userId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findAll($userId) {
|
||||||
|
$sql = 'SELECT * FROM *PREFIX*quicknotes_tags WHERE user_id = ?';
|
||||||
|
return $this->findEntities($sql, [$userId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user