zh Kooboo Logo Documents

Content

 

To create content and folders under a site, you can follow the steps mentioned in the previous charpters.
 
INSERT
 
To insert content, you need to create a content type first. Let's say we create a content type called "blog" with two fields: "title" and "summary". To insert a record, you can use the following code: 
 
var blog= k.content.blog.add({
title:'blog1',
summary:'My frist blog'
});
 
find findAll
 
You can use a similar querying approach to retrieve content from Kooboo as you would with a database
 
const {EQ} = k.content.operators(); 
var item = k.content.blog.find({title:{[EQ]:'blog1'}});  
k.response.write(item);  
 
Alternative
 
var item2 = k.content.blog.find("title=='blog1'");
k.response.write(item2);
 
In-memory QUERY
 
If the amount of content is not too large, you can load it into memory and perform JavaScript-based queries for faster access. Kooboo's content storage is highly efficient, so loading content into memory can provide improved query performance.
var blogs = k.content.blog.all().filter(o=>o.title=='blog1'); 
k.response.write(blogs);