Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: litedb-org/LiteDB
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.1.0
Choose a base ref
...
head repository: litedb-org/LiteDB
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing 586 changed files with 70,223 additions and 117,908 deletions.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''

---

**Version**
Which LiteDB version/OS/.NET framework version are you using. **(REQUIRED)**

**Describe the bug**
A clear and concise description of what the bug is.

**Code to Reproduce**
Write a small snippet to isolate your bug and could be possible to our team test. **(REQUIRED)**

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots/Stacktrace**
If applicable, add screenshots/stacktrace

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[SUGGESTION]"
labels: suggestion
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Question
about: Write your question about LiteDB
title: "[QUESTION]"
labels: question
assignees: ''

---


46 changes: 45 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# MacOS files
.DS_Store

# User-specific files
*.suo
*.user
@@ -179,4 +182,45 @@ FakesAssemblies/
# Nuget 3.0 Files
*.lock.json
*.nuget.props
*.nuget.targets
*.nuget.targets

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries

# User-specific configurations
.idea/libraries/
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/vcs.xml
.idea/jsLibraryMappings.xml
.idea/datasources.xml
.idea/dataSources.ids
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

### JetBrains+all Patch ###
# Ignores the whole idea folder
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
/LiteDB.BadJsonTest
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .travis/before-install-linux.sh

This file was deleted.

20 changes: 0 additions & 20 deletions .travis/before-install-osx.sh

This file was deleted.

14 changes: 14 additions & 0 deletions ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\LiteDB\LiteDB.csproj" />
</ItemGroup>

</Project>
98 changes: 98 additions & 0 deletions ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using LiteDB;
using LiteDB.Engine;

using System.Reflection.Emit;
using System.Reflection.PortableExecutable;

var password = "46jLz5QWd5fI3m4LiL2r";
var path = $"C:\\LiteDB\\Examples\\CrashDB_{DateTime.Now.Ticks}.db";

var settings = new EngineSettings
{
AutoRebuild = true,
Filename = path,
Password = password
};

var data = Enumerable.Range(1, 10_000).Select(i => new BsonDocument
{
["_id"] = i,
["name"] = Faker.Fullname(),
["age"] = Faker.Age(),
["created"] = Faker.Birthday(),
["lorem"] = Faker.Lorem(5, 25)
}).ToArray();

try
{
using (var db = new LiteEngine(settings))
{
#if DEBUG
db.SimulateDiskWriteFail = (page) =>
{
var p = new BasePage(page);

if (p.PageID == 248)
{
page.Write((uint)123123123, 8192-4);
}
};
#endif

db.Pragma("USER_VERSION", 123);

db.EnsureIndex("col1", "idx_age", "$.age", false);

db.Insert("col1", data, BsonAutoId.Int32);
db.Insert("col2", data, BsonAutoId.Int32);

var col1 = db.Query("col1", Query.All()).ToList().Count;
var col2 = db.Query("col2", Query.All()).ToList().Count;

Console.WriteLine("Inserted Col1: " + col1);
Console.WriteLine("Inserted Col2: " + col2);
}
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.Message);
}

Console.WriteLine("Recovering database...");

using (var db = new LiteEngine(settings))
{
var col1 = db.Query("col1", Query.All()).ToList().Count;
var col2 = db.Query("col2", Query.All()).ToList().Count;

Console.WriteLine($"Col1: {col1}");
Console.WriteLine($"Col2: {col2}");

var errors = new BsonArray(db.Query("_rebuild_errors", Query.All()).ToList()).ToString();

Console.WriteLine("Errors: " + errors);

}

/*
var errors = new List<FileReaderError>();
var fr = new FileReaderV8(settings, errors);
fr.Open();
var pragmas = fr.GetPragmas();
var cols = fr.GetCollections().ToArray();
var indexes = fr.GetIndexes(cols[0]);
var docs1 = fr.GetDocuments("col1").ToArray();
var docs2 = fr.GetDocuments("col2").ToArray();
Console.WriteLine("Recovered Col1: " + docs1.Length);
Console.WriteLine("Recovered Col2: " + docs2.Length);
Console.WriteLine("# Errors: ");
errors.ForEach(x => Console.WriteLine($"PageID: {x.PageID}/{x.Origin}/#{x.Position}[{x.Collection}]: " + x.Message));
*/

Console.WriteLine("\n\nEnd.");
Console.ReadKey();
Loading