新增 NOT LIKE、IS NULL 和 IS NOT NULL 操作符,并更新文档示例

This commit is contained in:
2025-12-31 13:11:07 +08:00
parent 8a4a720f5b
commit ae4fcacd9d
4 changed files with 97 additions and 8 deletions

View File

@@ -73,3 +73,24 @@ console.log(filter(products, "WHERE name LIKE '%Phone%'"));
console.log('\n=== 第二个字符任意的产品 (A_pple%) ===');
console.log(filter(products, "WHERE name LIKE 'A_pple%'"));
console.log('\n=== NOT LIKE 测试 ===');
console.log('\n=== 不包含 Apple 的产品 (NOT LIKE %Apple%) ===');
console.log(filter(products, "WHERE name NOT LIKE '%Apple%'"));
console.log('\n=== IS NULL 和 IS NOT NULL 测试 ===');
const usersWithNull = [
{ name: 'Alice', email: 'alice@example.com', age: 25 },
{ name: 'Bob', email: null, age: 30 },
{ name: 'Charlie', email: undefined, age: 35 },
{ name: 'Diana', email: 'diana@example.com', age: null }
];
console.log('\n=== Email 为 NULL 或 undefined 的用户 ===');
console.log(filter(usersWithNull, "WHERE email IS NULL"));
console.log('\n=== Email 不为 NULL 且不为 undefined 的用户 ===');
console.log(filter(usersWithNull, "WHERE email IS NOT NULL"));
console.log('\n=== Age 不为 NULL 且不为 undefined 的用户 ===');
console.log(filter(usersWithNull, "WHERE age IS NOT NULL"));