mirror of
https://github.com/qwertyforce/scenery.git
synced 2025-05-31 11:42:35 +00:00
include/exclude tags
This commit is contained in:
parent
901fc721ca
commit
d58ecadd66
@ -39,7 +39,16 @@ export default function Search(props: any) {
|
||||
export async function getServerSideProps(context: any) {
|
||||
if (context.query.q) {
|
||||
const tags = (context.query.q.split(',')).map((tag: string) => tag.trim())
|
||||
const images = await db_ops.image_ops.find_images_by_tags(tags)
|
||||
const include_tags=[]
|
||||
const exclude_tags=[]
|
||||
for(const tag of tags){
|
||||
if(tag[0]==='-'){
|
||||
exclude_tags.push(tag.slice(1))
|
||||
}else{
|
||||
include_tags.push(tag)
|
||||
}
|
||||
}
|
||||
const images = await db_ops.image_ops.find_images_by_tags(include_tags,exclude_tags)
|
||||
const images_on_page = 30
|
||||
const photos = []
|
||||
let page;
|
||||
|
@ -135,8 +135,13 @@ async function get_all_images(){
|
||||
return imgs
|
||||
}
|
||||
|
||||
async function find_images_by_tags(tags:Array<string>){
|
||||
const imgs = findDocuments("images", {tags:{$all:tags}})
|
||||
async function find_images_by_tags(include_tags:Array<string>,exclude_tags:Array<string>){
|
||||
console.log(include_tags)
|
||||
console.log(exclude_tags)
|
||||
const imgs = findDocuments("images", { $and: [
|
||||
{ tags: { $all: include_tags } },
|
||||
{ tags: { $not: { $all: exclude_tags }}}
|
||||
] })
|
||||
return imgs
|
||||
}
|
||||
async function find_image_by_sha512(hash:string){
|
||||
|
Loading…
x
Reference in New Issue
Block a user