Comparing version 0.6.4 to 0.6.5
{ | ||
"name": "notabase", | ||
"version": "0.6.4", | ||
"version": "0.6.5", | ||
"description": "API Wrapper For Notion's Database", | ||
@@ -15,2 +15,3 @@ "main": "src/notabase.js", | ||
"license": "ISC", | ||
"type": "module", | ||
"bugs": { | ||
@@ -17,0 +18,0 @@ "url": "https://github.com/mayneyao/Natabase/issues" |
@@ -40,3 +40,3 @@ # Notabase (WIP) | ||
// get my music data | ||
let db = await nb.fetch({ | ||
let db = await nb.fetchAll({ | ||
songs: "https://www.notion.so/2628769120ad41d998ec068d6e2eb410?v=e8e69ac68a8d483792c54541e4d8ba72", | ||
@@ -69,1 +69,10 @@ albums: "https://www.notion.so/15f1759f38a34fedaa79262812b707f0?v=b385656739214101b2b8a159092a52e8", | ||
``` | ||
## Todos | ||
### collection | ||
+ [ ] collection.addRow({title:"",Tags:["tag1"]}) // add new row | ||
+ [ ] collection.Tags = [...collection.Tags, newTag] // modify tags or mutil-select | ||
### row | ||
+ [ ] row.delete() // delete a row |
@@ -1,3 +0,1 @@ | ||
import { isPageId } from './utils' | ||
class Row { | ||
@@ -7,3 +5,3 @@ | ||
export default class Collection { | ||
class Collection { | ||
constructor(collectionId, collectionViewId, rawData, client) { | ||
@@ -191,2 +189,4 @@ this.collectionId = collectionId | ||
} | ||
} | ||
} | ||
module.exports = Collection |
@@ -1,3 +0,3 @@ | ||
import Collection from './collection' | ||
import { getBlockHashId, getFullBlockId, getUrlPageId } from './utils' | ||
const Collection = require('./collection') | ||
const { getBlockHashId, getFullBlockId, getUrlPageId } = require('./utils') | ||
@@ -7,3 +7,3 @@ | ||
export default class Notabase { | ||
class Notabase { | ||
constructor(options = {}) { | ||
@@ -159,2 +159,12 @@ this.blockStore = {} | ||
} | ||
} | ||
async fetchConfig(url, { key, value }) { | ||
let dbMap = {} | ||
let config = await this.fetch(url) | ||
config.rows.map(r => { | ||
dbMap[r[key]] = r._raw.properties[config.propsKeyMap[value].key][0][1][0][1] | ||
}) | ||
return dbMap | ||
} | ||
} | ||
module.exports = Notabase |
const Notabase = require('./src/notabase') | ||
console.log(Notabase) | ||
// node env | ||
@@ -9,4 +9,9 @@ let nb = new Notabase() | ||
let db = await nb._fetch("https://www.notion.so/gine/207fde2f97814adf964fb279382df205?v=f4fc2aad01a946999558111059d132d2") | ||
let dbMap = await nb.fetchConfig("https://www.notion.so/8fb3563c9a9847c59dcb5e7f5861054b?v=13dd6c4ed5db416d85b7dcddc018b2f2", { | ||
key: 'name', | ||
value: 'url' | ||
}) | ||
let db = await nb.fetchAll(dbMap) | ||
console.log(db) | ||
@@ -13,0 +18,0 @@ // let db = await nb.fetch({ |
519
77
Yes
25407
10