Created
September 6, 2022 13:33
-
-
Save barisusakli/2208831712379464bae99ca232de50af to your computer and use it in GitHub Desktop.
Search for categories with nodebb methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* globals require, console, process */ | |
'use strict'; | |
const nconf = require('nconf'); | |
nconf.file({ | |
file: 'config.json', | |
}); | |
nconf.defaults({ | |
base_dir: __dirname, | |
views_dir: './build/public/templates', | |
upload_path: 'public/uploads', | |
}); | |
const db = require('./src/database'); | |
db.init(async (err) => { | |
await db.initSessionStore(); | |
const meta = require('./src/meta'); | |
await meta.configs.init(); | |
if (err) { | |
console.log(`NodeBB could not connect to your database. Error: ${err.message}`); | |
process.exit(); | |
} | |
await search(); | |
console.log('done'); | |
process.exit(); | |
}); | |
async function search() { | |
const socketCategories = require('./src/socket.io/categories'); | |
const categories = require('./src/categories'); | |
const qs = { lang: 'en-US' }; | |
const search = 'other games'; | |
const result1 = await socketCategories.categorySearch({ uid: 1 }, { | |
privilege: 'topics:create', | |
states: ['watching', 'notwatching', 'ignoring'], | |
search: search, | |
parentCid: 0, | |
selectedCids: [1002], | |
query: qs, | |
}); | |
console.log('result1', result1); | |
const result2 = await categories.search({ | |
uid: 1, | |
query: search, | |
qs: qs, | |
paginate: false, | |
}); | |
console.log('result2', result2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment